diff --git a/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java b/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java index 33362c9b..72aa638c 100644 --- a/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java +++ b/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java @@ -69,7 +69,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy } protected void load(List files, boolean recursive) { - List entries = new ArrayList(); + Set entries = new LinkedHashSet(); LinkedList queue = new LinkedList(files); while (queue.size() > 0) { @@ -63,8 +65,7 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy if (recursive && LIST_FILES.accept(f)) { // don't use new Scanner(File) because of BUG 6368019 (http://bugs.sun.com/view_bug.do?bug_id=6368019) - try { - Scanner scanner = new Scanner(createTextReader(f)); + try (Scanner scanner = new Scanner(createTextReader(f))) { List paths = new ArrayList(); while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); @@ -75,7 +76,6 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy } } } - scanner.close(); if (paths.isEmpty()) { entries.add(f); // treat as simple text file @@ -92,7 +92,7 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy } } - publish(FastFile.create(entries).toArray(new File[0])); + publish(FastFile.create(entries)); } @Override diff --git a/source/net/filebot/ui/rename/NamesListTransferablePolicy.java b/source/net/filebot/ui/rename/NamesListTransferablePolicy.java index 2b757e8b..a26d3efc 100644 --- a/source/net/filebot/ui/rename/NamesListTransferablePolicy.java +++ b/source/net/filebot/ui/rename/NamesListTransferablePolicy.java @@ -2,6 +2,7 @@ package net.filebot.ui.rename; import static java.awt.datatransfer.DataFlavor.*; import static java.util.Arrays.*; +import static java.util.Collections.*; import static net.filebot.MediaTypes.*; import static net.filebot.hash.VerificationUtilities.*; import static net.filebot.ui.transfer.FileTransferable.*; @@ -97,7 +98,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy { loadTorrentFiles(files, values); } else { // load all files from the given folders recursively up do a depth of 32 - values.addAll(FastFile.create(listFiles(files))); + addAll(values, FastFile.create(listFiles(files))); } model.addAll(values); diff --git a/source/net/filebot/util/FastFile.java b/source/net/filebot/util/FastFile.java index 5a93fa71..604b0a20 100644 --- a/source/net/filebot/util/FastFile.java +++ b/source/net/filebot/util/FastFile.java @@ -199,14 +199,8 @@ public class FastFile extends File { throw new UnsupportedOperationException(); } - public static List create(Collection files) { - List result = new ArrayList(files.size()); - - for (File file : files) { - result.add(new FastFile(file.getPath())); - } - - return result; + public static FastFile[] create(Collection files) { + return files.stream().map(f -> new FastFile(f.getPath())).toArray(FastFile[]::new); } }