public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream("e:\\aaaaaa\\ccc.txt");
fos = new FileOutputStream("number.txt");
int hc = 0;
while((hc = fis.read())!=-1){
fos.write(hc);
}
} catch (IOException e) {
System.out.println(e);
throw new RuntimeException("文件复制失败");
}finally{
try {
if(fos!=null)
fos.close();
} catch (IOException e2) {
throw new RuntimeException("释放资源失败");
}finally{
try {
if(fis!=null)
fis.close();
} catch (IOException e3) {
throw new RuntimeException("释放资源失败");
}
}
}
}
这里的throw 语句为啥不能用System.out.println("文件复制失败"); |
|