Version 1.3.1: new Version class
[nikiroo-utils.git] / src / be / nikiroo / utils / IOUtils.java
index 92e312874599c6652454551bdd096cbc7b531226..eb105e2698535e325ed602fc0b3ed50f7e0b16b4 100644 (file)
@@ -232,7 +232,7 @@ public class IOUtils {
         * @throws IOException
         *             in case of IO error
         */
-       static public BufferedImage toImage(InputStream in) throws IOException {
+       public static BufferedImage toImage(InputStream in) throws IOException {
                MarkableFileInputStream tmpIn = null;
                File tmp = null;
                try {
@@ -329,6 +329,23 @@ public class IOUtils {
                return image;
        }
 
+       /**
+        * Open the given /-separated resource (from the binary root).
+        * 
+        * @param name
+        *            the resource name
+        * 
+        * @return the opened resource if found, NLL if not
+        */
+       public static InputStream openResource(String name) {
+               ClassLoader loader = IOUtils.class.getClassLoader();
+               if (loader == null) {
+                       loader = ClassLoader.getSystemClassLoader();
+               }
+
+               return loader.getResourceAsStream(name);
+       }
+
        /**
         * Return the EXIF transformation flag of this image if any.
         * 
@@ -344,7 +361,7 @@ public class IOUtils {
         * @throws IOException
         *             in case of IO error
         */
-       static private int getExifTransorm(InputStream in) throws IOException {
+       private static int getExifTransorm(InputStream in) throws IOException {
                int[] exif_data = new int[100];
                int set_flag = 0;
                int is_motorola = 0;