I was debugging something in ModuleTests, trying to find out if there
are resource leaks. They were not in this class but in FileUtil - see
next commit. However, the little refactoring here does not hurt either.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
}
private void copyResourcesFromJarFile(File jarFile) throws IOException {
- JarInputStream inStream = null;
- try {
- inStream = new JarInputStream(new FileInputStream(jarFile));
+ try (JarInputStream inStream = new JarInputStream(new FileInputStream(jarFile))) {
while (true) {
ZipEntry entry = inStream.getNextEntry();
if (entry == null) {
inStream.closeEntry();
}
- } finally {
- if (inStream != null) {
- inStream.close();
- }
}
}