From a6271b9c1322109042a04a6aaf1266dba49d6463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Mon, 14 Aug 2023 11:07:54 +0800 Subject: [PATCH] =?UTF-8?q?pom=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pqs-device/device-boot/pom.xml | 12 ++-- .../device/pq/utils/SocketClientComm.java | 62 ++++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/pqs-device/device-boot/pom.xml b/pqs-device/device-boot/pom.xml index ff807b7c4..d881e47d5 100644 --- a/pqs-device/device-boot/pom.xml +++ b/pqs-device/device-boot/pom.xml @@ -21,16 +21,16 @@ - - - - - + com.njcn + pq-device-boot + ${project.version} + + com.njcn diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/utils/SocketClientComm.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/utils/SocketClientComm.java index fc2987b8b..85c778f4f 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/utils/SocketClientComm.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/utils/SocketClientComm.java @@ -6,10 +6,7 @@ import lombok.extern.slf4j.Slf4j; import net.sf.json.JSONObject; import org.springframework.stereotype.Component; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; +import java.io.*; import java.net.InetSocketAddress; import java.net.Socket; import java.nio.charset.StandardCharsets; @@ -72,31 +69,7 @@ public class SocketClientComm { e.printStackTrace(); }finally{ - //一些必要的清理工作 - if(in != null){ - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - in = null; - } - if(out != null){ - try { - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - out = null; - } - if(socket != null){ - try { - socket.close(); - } catch (IOException e) { - e.printStackTrace(); - } - socket = null; - } + //System.out.println("end---"); } @@ -104,4 +77,35 @@ public class SocketClientComm { } + + + private void safeCloseStream(InputStream in,OutputStream out,Socket socket){ + //一些必要的清理工作 + if(in != null){ + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + in = null; + } + if(out != null){ + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + out = null; + } + if(socket != null){ + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + socket = null; + } + } + + }