fix API: изменение работы метода SaveResource
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<groupId>asys</groupId>
|
<groupId>asys</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
<version>0.8</version>
|
<version>0.9</version>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -43,17 +43,19 @@ public class ASysUtils {
|
|||||||
System.out.printf(format+"\n", objects);
|
System.out.printf(format+"\n", objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveResource(String resource, File saveTo) throws IOException {
|
public static void SaveResource(InputStream resourceAsStream, File saveTo) throws IOException {
|
||||||
InputStream stream = ASysUtils.class.getResourceAsStream(resource);
|
if (resourceAsStream == null) {
|
||||||
|
throw new NullPointerException("Resource not found! (stream == null)");
|
||||||
|
}
|
||||||
FileOutputStream fos = new FileOutputStream(saveTo);
|
FileOutputStream fos = new FileOutputStream(saveTo);
|
||||||
byte[] buff = new byte[65536];
|
byte[] buff = new byte[65536];
|
||||||
int len;
|
int len;
|
||||||
while ((len = stream.read(buff)) > 0) {
|
while ((len = resourceAsStream.read(buff)) > 0) {
|
||||||
fos.write(buff, 0, len);
|
fos.write(buff, 0, len);
|
||||||
}
|
}
|
||||||
fos.flush();
|
fos.flush();
|
||||||
fos.close();
|
fos.close();
|
||||||
stream.close();
|
resourceAsStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<String, Object> getCommandListByAnnotationMethods(String scope, Class<?> clazz) {
|
private static Dictionary<String, Object> getCommandListByAnnotationMethods(String scope, Class<?> clazz) {
|
||||||
|
|||||||
Reference in New Issue
Block a user