From a63ae4ce1523c211629dea3615dda5caa210d2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Mon, 21 Aug 2023 14:27:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E7=BA=A7=E7=AE=97=E6=B3=95bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/advance/utils/JnaCallDllOrSo.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java index 708190984..a9d252e49 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java @@ -31,20 +31,17 @@ public class JnaCallDllOrSo { //linux操作系统 this.nameDll = "lib" + name + "_dll"; suffix = ".so"; +// this.path = "/usr/local/jarfiles/advanceboot/BOOT-INF/classes/"; + //this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"); } else { this.nameDll = name; +// this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replaceFirst("/", ""), "UTF-8"); } - File dockerFile = new File("/usr/local/dllFile/".concat(this.nameDll.concat(suffix))); - if(dockerFile.exists()){ - this.path = dockerFile.getAbsolutePath(); - }else { - dockerFile.mkdirs(); - dockerFile.createNewFile(); - } - + File tempFile; try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(this.nameDll.concat(suffix))) { - try (FileOutputStream outputStream = new FileOutputStream(dockerFile)) { + tempFile = File.createTempFile(this.nameDll, suffix); + try (FileOutputStream outputStream = new FileOutputStream(tempFile)) { byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { @@ -52,7 +49,9 @@ public class JnaCallDllOrSo { } } } - this.path = dockerFile.getAbsolutePath(); + this.path = tempFile.getAbsolutePath(); + System.out.println(1); + System.out.println(1); } catch (Exception e) { log.error(e.getMessage()); } @@ -63,6 +62,8 @@ public class JnaCallDllOrSo { public String getStrpath() { return this.path; +// String aa = this.path + this.nameDll; +// return aa.replace("/", File.separator); } public void setPath() {