各种连接,如数据库连接、网络连接和IO连接等,文件读写等,可以使用 try-with-resources 读取完文件,自动资源释放
try (RandomAccessFile raf = new RandomAccessFile(filePath, “r”)😉 {
Image image = null;
while((image = parseImage(raf)) != null){
imageList.add(image);
}
return imageList;
} catch(Exception e){
log.error(“parse file error, path: {},”, path, e);
return null;
}
538