//load指定dll路径
System.load(path + System.getProperty("file.separator")+ "aaa.dll");
//load jar中的dll
private static void loadJar(String name, String ext) throws IOException,
SecurityException, UnsatisfiedLinkError {
String sep = "/";// System.getProperty("file.separator");
String path = sep + "resources" + sep + name + ext;
String tmpPath = Client.class.getClassLoader().getResource("").getPath();
File tmp = new File(tmpPath);
if (!tmp.exists()) {
tmp.mkdir();
}
File jni = new File(tmpPath + sep + name + ext);
if (!jni.exists()) {
InputStream in = Client.class.getResourceAsStream(path);
FileOutputStream out = new FileOutputStream(jni);
byte[] buf = new byte[1024];
int i;
while ((i = in.read(buf)) != -1) {
out.write(buf, 0, i);
}
in.close();
out.close();
jni.deleteOnExit();
}
System.load(jni.toString());
}
System.load(path + System.getProperty("file.separator")+ "aaa.dll");
//load jar中的dll
private static void loadJar(String name, String ext) throws IOException,
SecurityException, UnsatisfiedLinkError {
String sep = "/";// System.getProperty("file.separator");
String path = sep + "resources" + sep + name + ext;
String tmpPath = Client.class.getClassLoader().getResource("").getPath();
File tmp = new File(tmpPath);
if (!tmp.exists()) {
tmp.mkdir();
}
File jni = new File(tmpPath + sep + name + ext);
if (!jni.exists()) {
InputStream in = Client.class.getResourceAsStream(path);
FileOutputStream out = new FileOutputStream(jni);
byte[] buf = new byte[1024];
int i;
while ((i = in.read(buf)) != -1) {
out.write(buf, 0, i);
}
in.close();
out.close();
jni.deleteOnExit();
}
System.load(jni.toString());
}