Преглед на файлове

修改读取的结果

tags/v1.0.0^2
林万龙 преди 3 години
родител
ревизия
7854e0b232
променени са 1 файла, в които са добавени 20 реда и са изтрити 13 реда
  1. +20
    -13
      src/main/java/com/telpo/dipperposition/common/SocketClient.java

+ 20
- 13
src/main/java/com/telpo/dipperposition/common/SocketClient.java Целия файл

@@ -52,28 +52,35 @@ public class SocketClient {
String reply=null;
//输入流
InputStream is=socket.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
//BufferedReader br=new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];

StringBuffer ackResultBuf= new StringBuffer();
//StringBuffer ackResultBuf= new StringBuffer();
//String ackHexOut = HexConvert.convertStringToHex(ackAckCheckRef);
reply=br.readLine();
while(reply!=null){
//log.debug("接收服务器的信息:"+reply);
//if (ackHexOut.equals(reply)) {
ackResultBuf.append(reply);
reply=br.readLine();
// break;
//}
// reply=br.readLine();
// while(reply!=null){
// //log.debug("接收服务器的信息:"+reply);
// //if (ackHexOut.equals(reply)) {
// ackResultBuf.append(reply);
// reply=br.readLine();
// // break;
// //}
// }
int rc = 0;
while ((rc = is.read(buff, 0, 100)) > 0) {
swapStream.write(buff, 0, rc);
}
byte[] in2b = swapStream.toByteArray();
//String ackResult = HexConvert.convertHexToString(ackResultBuf.toString());
//4.关闭资源
br.close();
swapStream.close();
is.close();
pw.close();
os.close();
//log.debug(ackResult);
log.debug("接收服务器的信息:"+ackResultBuf.toString());
return ackResultBuf.toString();
log.debug("接收服务器的信息:"+in2b.toString());
return in2b.toString();
} catch (IOException e) {
log.error("Socket sendCmd Error:" + e.getMessage());
return null;


Loading…
Отказ
Запис