如果有需要关闭的资源(比如文件、socket)想让try-catch关掉,可以用try-with-resource语法:
try(
FileReader fr = new FileReader(src);
BufferedReader br = new BufferedReader(fr);
FileWriter wr = new FileWriter(target)
) {}
catch(Exception e) {}
如果有需要关闭的资源(比如文件、socket)想让try-catch关掉,可以用try-with-resource语法:
try(
FileReader fr = new FileReader(src);
BufferedReader br = new BufferedReader(fr);
FileWriter wr = new FileWriter(target)
) {}
catch(Exception e) {}