소스 검색

修改读取的结果

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…
취소
저장