pom提交

This commit is contained in:
2023-08-14 11:07:54 +08:00
parent 4d4f1f8344
commit a6271b9c13
2 changed files with 39 additions and 35 deletions

View File

@@ -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;
}
}
}