Kaynağa Gözat

修改读取的结果

tags/v1.0.0^2
林万龙 3 yıl önce
ebeveyn
işleme
7854e0b232
1 değiştirilmiş dosya ile 20 ekleme ve 13 silme
  1. +20
    -13
      src/main/java/com/telpo/dipperposition/common/SocketClient.java

+ 20
- 13
src/main/java/com/telpo/dipperposition/common/SocketClient.java Dosyayı Görüntüle

@@ -52,28 +52,35 @@ public class SocketClient {
String reply=null; String reply=null;
//输入流 //输入流
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));
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];


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


Yükleniyor…
İptal
Kaydet