mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-11 02:39:37 +07:00
Use try-with-resources (IDEA-CR-24263)
This commit is contained in:
@@ -149,15 +149,12 @@ public class TarUtil {
|
||||
|
||||
public static void extract(@NotNull File file, @NotNull File outputDir, @Nullable FilenameFilter filenameFilter, boolean overwrite)
|
||||
throws IOException {
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
GzipCompressorInputStream gcis = new GzipCompressorInputStream(fis);
|
||||
TarArchiveInputStream tis = new TarArchiveInputStream(gcis);
|
||||
try {
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(file);
|
||||
GzipCompressorInputStream gcis = new GzipCompressorInputStream(fis);
|
||||
TarArchiveInputStream tis = new TarArchiveInputStream(gcis)) {
|
||||
extract(tis, outputDir, filenameFilter, overwrite);
|
||||
}
|
||||
finally {
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void extract(@NotNull final TarArchiveInputStream tis,
|
||||
@@ -219,10 +216,8 @@ public class TarUtil {
|
||||
* update an existing jar file. Adds/replace files specified in relpathToFile map
|
||||
*/
|
||||
public static void update(InputStream in, OutputStream out, Map<String, File> relpathToFile) throws IOException {
|
||||
TarArchiveInputStream tis = new TarArchiveInputStream(in);
|
||||
TarArchiveOutputStream tos = new TarArchiveOutputStream(out);
|
||||
|
||||
try {
|
||||
try (TarArchiveInputStream tis = new TarArchiveInputStream(in);
|
||||
TarArchiveOutputStream tos = new TarArchiveOutputStream(out)) {
|
||||
// put the old entries first, replace if necessary
|
||||
TarArchiveEntry e;
|
||||
while ((e = tis.getNextTarEntry()) != null) {
|
||||
@@ -256,9 +251,5 @@ public class TarUtil {
|
||||
addFileToTar(tos, file, path, null, null);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
tis.close();
|
||||
tos.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<annotation-paths>
|
||||
<root url="file://$MODULE_DIR$/anno" />
|
||||
|
||||
Reference in New Issue
Block a user