感觉是下面这个方法可能有问题: length = instream.available(); public int available(): Returns the number of bytes that can be read from this input stream without blocking. try: while((length = instream.read(bContext,0,1024))!=-1) { System.out.println(new String(bContext.getBytes(),0,length)); }
或者,在文件发送完后再发送一个自己定义的特殊标志符号,接收端检测结尾符号…………
现在在每一次流的结尾都有空字符啊
length = instream.available();
public int available():
Returns the number of bytes that can be read from this input stream without blocking. try:
while((length = instream.read(bContext,0,1024))!=-1)
{
System.out.println(new String(bContext.getBytes(),0,length));
}