【发布时间】:2015-02-15 15:21:16
【问题描述】:
我有问题... 我有一个套接字的 InputStream 和一个 FileOutputStream。
System.out.println("uploading...");
FileOutputStream fos = uploads.get(a); //Get the FileOutputStream from the HashMap...
byte[] buffer = new byte[0xFFF];
for (int len; (len = s.getInputStream().read(buffer)) != -1;) {
fos.write(buffer, 0, len);
}
System.out.println("test"); //not called
fos.flush();
fos.close();
s.close(); //not called
我也尝试过使用 Apache Commons-IO 进行复制,但也没有成功...
你有什么想法吗?我认为有错误,我只是看不到它......
谢谢卢卡
【问题讨论】:
-
不,没有例外...
-
我刚刚将 Streams 放入带有 Auth-Object 的 Hashmap...
-
不,输出中没有测试...
-
哦,您应该知道文件已写入磁盘...可以,但是之后的代码不起作用...不知道为什么...
-
谢谢提图斯!不知道要关闭另一边的socket才能关闭...
标签: java loops networking stream