我的程序要实现多个文件的连续传输,不知道是否因为输入流没有关闭的原因,接收端无法检测到流的末尾,所以之一阻塞,希望高手帮忙解决。接收端:
while((len=bis.read(buf,0,1024*10))!=-1)
{
  bos.write(buf,0,len);
  bos.flush();
  System.out.println(len);
}
System.out.println("end");
bos.close();
fos.close();
os.write(1);输出信息:
creating outside\a.doc......
fileLen: 24064
10240
10240
3584发送端:
while((len=bis.read(fileBuf,0,1024*10))!=-1)
{
  bos.write(fileBuf,0,len);
  bos.flush();
 }   
  bis.close();
  fis.close();
  System.out.println("file end");
  is.read();输出信息:
file end

解决方案 »

  1.   

    发送端没有关闭流,接受端当然收不到结束标志。
    发送端:
    while((len=bis.read(fileBuf,0,1024*10))!=-1)
    {
      bos.write(fileBuf,0,len);
      bos.flush();
     }  
    ===========================
     bos.close();
    ===========================
      bis.close();
      fis.close();
      System.out.println("file end");
      is.read();
      

  2.   

    我是想通过一个socket来实现多个文件传输,bos.close好像会底层得输出流关闭吧?回qq7338367(.深秋小雨:让一切归于简单 快乐在指尖绽放):
    做的是局域网文件夹传送