@ -54,9 +54,7 @@ public class FileReporterTest {
|
||||
}
|
||||
|
||||
private String readFile(File file) throws IOException {
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line = reader.readLine();
|
||||
while (line != null) {
|
||||
@ -67,10 +65,6 @@ public class FileReporterTest {
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,7 @@ public class ZipFileExtractor {
|
||||
* @throws Exception if any error happens during extraction
|
||||
*/
|
||||
public static void extractZipFile(Path zipPath, Path tempDir) throws Exception {
|
||||
ZipFile zip = new ZipFile(zipPath.toFile());
|
||||
try {
|
||||
try (ZipFile zip = new ZipFile(zipPath.toFile())) {
|
||||
Enumeration<ZipArchiveEntry> entries = zip.getEntries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipArchiveEntry entry = entries.nextElement();
|
||||
@ -57,8 +56,6 @@ public class ZipFileExtractor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
zip.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,15 +67,12 @@ public class ZipFileExtractor {
|
||||
*/
|
||||
public static List<String> readZipFile(Path zipPath) throws Exception {
|
||||
List<String> result = new ArrayList<>();
|
||||
ZipFile zip = new ZipFile(zipPath.toFile());
|
||||
try {
|
||||
try (ZipFile zip = new ZipFile(zipPath.toFile())) {
|
||||
Enumeration<ZipArchiveEntry> entries = zip.getEntries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipArchiveEntry entry = entries.nextElement();
|
||||
result.add(entry.getName());
|
||||
}
|
||||
} finally {
|
||||
zip.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user