public void automaticallyCloseResource() {
File file = new File("./tmp.txt");
try (FileInputStream inputStream = new FileInputStream(file);)
{ // use the inputStream to read a file }
catch (FileNotFoundException e)
{ log.error(e); }
catch (IOException e)
{ log.error(e); }
}
著作权归@pdai所有 原文链接:https://pdai.tech/md/interview/x-interview.html