socket中Inputstream.read()方法出现问题,一直阻塞; 10
InputStreaminputStream=socket.getInputStream();ByteArrayOutputStreamoutputStream=newB...
InputStream inputStream = socket.getInputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[512];
int len = -1;
len = inputStream.read(bytes);
System.out.println(len + "====================");
outputStream.write(bytes, 0, len);
while ((len = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, len);
outputStream.flush();
}
bytes = outputStream.toByteArray();
System.out.println("=============结束了====================="
+ bytes.length);
inputStream.read()在读取完信息后,一直阻塞着,不走最后一句,也没有异常抛出? 展开
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[512];
int len = -1;
len = inputStream.read(bytes);
System.out.println(len + "====================");
outputStream.write(bytes, 0, len);
while ((len = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, len);
outputStream.flush();
}
bytes = outputStream.toByteArray();
System.out.println("=============结束了====================="
+ bytes.length);
inputStream.read()在读取完信息后,一直阻塞着,不走最后一句,也没有异常抛出? 展开
展开全部
InputStream inputStream = socket.getInputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[512];
int len = -1;
len = inputStream.read(bytes);
System.out.println(len + "====================");
outputStream.write(bytes, 0, len);
while ((len = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, len);
outputStream.flush();
socket.shutdownOutput();
}
bytes = outputStream.toByteArray();
System.out.println("=============结束了====================="
+ bytes.length);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[512];
int len = -1;
len = inputStream.read(bytes);
System.out.println(len + "====================");
outputStream.write(bytes, 0, len);
while ((len = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, len);
outputStream.flush();
socket.shutdownOutput();
}
bytes = outputStream.toByteArray();
System.out.println("=============结束了====================="
+ bytes.length);
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询