diff --git a/API/pom.xml b/API/pom.xml index a7d6f7d..9cff47c 100644 --- a/API/pom.xml +++ b/API/pom.xml @@ -19,7 +19,7 @@ asys api - 0.8 + 0.9 bundle diff --git a/API/src/main/java/asys/api/ASysUtils.java b/API/src/main/java/asys/api/ASysUtils.java index 8cb6f78..3e837c0 100644 --- a/API/src/main/java/asys/api/ASysUtils.java +++ b/API/src/main/java/asys/api/ASysUtils.java @@ -43,17 +43,19 @@ public class ASysUtils { System.out.printf(format+"\n", objects); } - public static void SaveResource(String resource, File saveTo) throws IOException { - InputStream stream = ASysUtils.class.getResourceAsStream(resource); + public static void SaveResource(InputStream resourceAsStream, File saveTo) throws IOException { + if (resourceAsStream == null) { + throw new NullPointerException("Resource not found! (stream == null)"); + } FileOutputStream fos = new FileOutputStream(saveTo); byte[] buff = new byte[65536]; int len; - while ((len = stream.read(buff)) > 0) { + while ((len = resourceAsStream.read(buff)) > 0) { fos.write(buff, 0, len); } fos.flush(); fos.close(); - stream.close(); + resourceAsStream.close(); } private static Dictionary getCommandListByAnnotationMethods(String scope, Class clazz) {