Browse Source

修改读取的结果

tags/v1.0.0^2
林万龙 4 years ago
parent
commit
6b6f2b23ba
1 changed files with 12 additions and 9 deletions
  1. +12
    -9
      src/main/java/com/telpo/dipperposition/common/SocketClient.java

+ 12
- 9
src/main/java/com/telpo/dipperposition/common/SocketClient.java View File

@@ -54,22 +54,25 @@ public class SocketClient {
InputStream is=socket.getInputStream(); InputStream is=socket.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); BufferedReader br=new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));


String ackResult="";
String ackHexOut = HexConvert.convertStringToHex(ackAckCheckRef);
while(!((reply=br.readLine())==null)){
log.debug("接收服务器的信息:"+reply);
if (ackHexOut.equals(reply)) {
reply=br.readLine();
ackResult = HexConvert.convertHexToString(reply);
break;
}
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;
//}
} }
String ackResult = HexConvert.convertHexToString(ackResultBuf.toString());
//4.关闭资源 //4.关闭资源
br.close(); br.close();
is.close(); is.close();
pw.close(); pw.close();
os.close(); os.close();
log.debug(ackResult); log.debug(ackResult);
log.debug("接收服务器的信息:"+ackResult);
return ackResult; return ackResult;
} catch (IOException e) { } catch (IOException e) {
log.error("Socket sendCmd Error:" + e.getMessage()); log.error("Socket sendCmd Error:" + e.getMessage());


Loading…
Cancel
Save