Java 代码没有被调用
Java code does not get called
我有一个问题...
我有一个由套接字和一个 FileOutputStream 组成的 InputStream。
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 进行复制,但它也不起作用...
你有什么想法吗?我认为有错误,我只是看不到...
谢谢卢卡
您必须 Try/Catch 或抛出该 fos,所以我的猜测是您抛出异常,然后不从调用方法处理它。你下面的代码没有被执行的原因是抛出异常后,它立即停止当前方法,并且returns到抛出异常的调用方法。
我有一个问题... 我有一个由套接字和一个 FileOutputStream 组成的 InputStream。
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 进行复制,但它也不起作用...
你有什么想法吗?我认为有错误,我只是看不到...
谢谢卢卡
您必须 Try/Catch 或抛出该 fos,所以我的猜测是您抛出异常,然后不从调用方法处理它。你下面的代码没有被执行的原因是抛出异常后,它立即停止当前方法,并且returns到抛出异常的调用方法。