风潇潇1991 2017-06-15 03:18 采纳率: 0%
浏览 1282

HTML,从request中读取消息卡住

public Request(InputStream is) throws IOException{
this();
this.is=new BufferedInputStream(is);

    //此代码块运行正常。
    byte[] flush = new byte[20480];
    int len = is.read(flush);
    allInfo = new String(flush,0,len);

// byte[] flush = new byte[1024];
// int len =0;
// StringBuilder sb = new StringBuilder();
// try {
// while(-1!=(len=is.read(flush))){
// sb.append(new String(flush,0,len));
// }
// } catch (IOException e) {
// allInfo=null;
// return;
// }
// allInfo = (sb.toString()).trim();
// System.out.println(allInfo);
parseAllInfo();
}

以上代码可顺利运行,但是使用注释部分的代码块进行读取,就会在 while(-1!=(len=is.read(flush)))此行卡住,请问存在什码中题?代码中InputSmtrea is ,是通过(SocketSever.accpt).getinputStream来获取的

  • 写回答

2条回答 默认 最新

  • 丵鹰 2017-06-15 03:19
    关注

    while(-1!=(len=is.read(flush))) 你上面使用的是this.is, this.is=new BufferedInputStream(is);是不是这里也要改成this.is

    评论

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常