41 lines
843 B
Java
41 lines
843 B
Java
package org.hwo.platform;
|
|
|
|
import java.io.FileOutputStream;
|
|
import java.io.InputStream;
|
|
|
|
import org.hwo.platform.natives.NativeLoader;
|
|
|
|
public class Ressource {
|
|
|
|
public static boolean extract(Class<?> clazz,String resource,String filename){
|
|
return extract(
|
|
clazz.getResourceAsStream(resource),
|
|
filename
|
|
);
|
|
}
|
|
|
|
public static boolean extract(String resource,String filename){
|
|
return extract(
|
|
NativeLoader.class.getResourceAsStream(resource),
|
|
filename
|
|
);
|
|
}
|
|
|
|
private static boolean extract(InputStream in,String filename){
|
|
try {
|
|
FileOutputStream fos = new FileOutputStream(filename);
|
|
byte[] buffer = new byte[in.available()];
|
|
in.read(buffer);
|
|
fos.write(buffer);
|
|
fos.close();
|
|
|
|
return true;
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
}
|