62,628
社区成员
发帖
与我相关
我的任务
分享try{fileInputStream=new FileInputStream(pic);
byte [] bufstring=new byte[1024];
FileOutputStream fileOutputStream=new FileOutputStream("C:/Users/wowowo/Desktop/ww.png");后边没写,fileOuputStream是有警告的,而 fileInpuStream是没有警告的,同样在try外面先定义一下fileOutStream警告消失 为什么会这样?try {
FileInputStream in = new FileInputStream("xxx");
try {
FileOutputStream out = new FileOutputStream("xxx");
try {
// do xxx
} finally {
out.close();
}
} finally {
in.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
InputStream in;
try{
in = new FileInputStream("ip.dat");
.....
} catch(IOException | FileNotFoundException ex) {
logger.error("0x2AD001", ex);
} finally {
if(null != in){
try{
in.close();
}catch(IOException e){
logger.error("0x2AD002", ex)
}
}
}