Browse Source

Little optimization

pull/376/head
Decebal Suiu 5 years ago
parent
commit
a01cd8ac5b
  1. 5
      pf4j/src/main/java/org/pf4j/util/FileUtils.java

5
pf4j/src/main/java/org/pf4j/util/FileUtils.java

@ -46,6 +46,8 @@ public class FileUtils {
private static final Logger log = LoggerFactory.getLogger(FileUtils.class); private static final Logger log = LoggerFactory.getLogger(FileUtils.class);
private static final boolean IS_WINDOWS_OS = System.getProperty("os.name").startsWith("Windows");
public static List<String> readLines(Path path, boolean ignoreComments) throws IOException { public static List<String> readLines(Path path, boolean ignoreComments) throws IOException {
File file = path.toFile(); File file = path.toFile();
if (!file.isFile()) { if (!file.isFile()) {
@ -232,8 +234,7 @@ public class FileUtils {
public static Path getPath(URI uri, String first, String... more) throws IOException { public static Path getPath(URI uri, String first, String... more) throws IOException {
FileSystem fileSystem = getFileSystem(uri); FileSystem fileSystem = getFileSystem(uri);
Path path = fileSystem.getPath(first, more); Path path = fileSystem.getPath(first, more);
boolean isWindowsOS = System.getProperty("os.name").startsWith("Windows"); if (IS_WINDOWS_OS && "jar".equals(uri.getScheme())) {
if (isWindowsOS && "jar".equals(uri.getScheme())) {
// it's a ZipFileSystem // it's a ZipFileSystem
fileSystem.close(); fileSystem.close();
} }

Loading…
Cancel
Save