Prefer Path.of() over Paths.get()

This commit is contained in:
P0nk
2022-08-11 19:01:40 +02:00
parent 297d5b25f0
commit d691dc1e18
13 changed files with 26 additions and 32 deletions

View File

@@ -2,7 +2,6 @@ package provider.wz;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public enum WZFiles {
QUEST("Quest"),
@@ -28,7 +27,7 @@ public enum WZFiles {
}
public Path getFile() {
return Paths.get(DIRECTORY).resolve(fileName);
return Path.of(DIRECTORY, fileName);
}
public String getFilePath() {
@@ -38,7 +37,7 @@ public enum WZFiles {
private static String getWzDirectory() {
// Either provide a custom directory path through the "wz-path" property when launching the .jar, or don't provide one to use the default "wz" directory
String propertyPath = System.getProperty("wz-path");
if (propertyPath != null && Files.isDirectory(Paths.get(propertyPath))) {
if (propertyPath != null && Files.isDirectory(Path.of(propertyPath))) {
return propertyPath;
}

View File

@@ -21,6 +21,8 @@
*/
package provider.wz;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import provider.Data;
import provider.DataDirectoryEntry;
import provider.DataProvider;
@@ -32,9 +34,6 @@ import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class XMLWZFile implements DataProvider {
private static final Logger log = LoggerFactory.getLogger(DataProvider.class);
private final Path root;
@@ -60,7 +59,7 @@ public class XMLWZFile implements DataProvider {
}
}
} catch (IOException e) {
log.warn("Can not open file/directory at " + lroot);
log.warn("Can not open file/directory at " + lroot.toAbsolutePath().toString());
}
}
@@ -69,7 +68,7 @@ public class XMLWZFile implements DataProvider {
Path dataFile = root.resolve(path + ".xml");
Path imageDataDir = root.resolve(path);
if (!Files.exists(dataFile)) {
return null;// bitches
return null;
}
final XMLDomMapleData domMapleData;
try (FileInputStream fis = new FileInputStream(dataFile.toString())) {