X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FIOUtils.java;h=eb105e2698535e325ed602fc0b3ed50f7e0b16b4;hb=refs%2Ftags%2Fnikiroo-utils-1.3.1;hp=92e312874599c6652454551bdd096cbc7b531226;hpb=b607df60a14942d9aa6383144470a237934eecfc;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/IOUtils.java b/src/be/nikiroo/utils/IOUtils.java index 92e3128..eb105e2 100644 --- a/src/be/nikiroo/utils/IOUtils.java +++ b/src/be/nikiroo/utils/IOUtils.java @@ -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;