Message file verifier: allow to simply enter the language code instead of full path
- To check a single file just enter the language file, e.g. "es" - Pass File object to MessageFileVerifier instead of String path that will be constructed to a File again...
This commit is contained in:
@@ -3,6 +3,7 @@ package tools.utils;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.List;
|
||||
@@ -22,10 +23,14 @@ public final class FileUtils {
|
||||
}
|
||||
|
||||
public static void writeToFile(String outputFile, String contents) {
|
||||
writeToFile(Paths.get(outputFile), contents);
|
||||
}
|
||||
|
||||
public static void writeToFile(Path path, String contents) {
|
||||
try {
|
||||
Files.write(Paths.get(outputFile), contents.getBytes());
|
||||
Files.write(path, contents.getBytes());
|
||||
} catch (IOException e) {
|
||||
throw new UnsupportedOperationException("Failed to write to file '" + outputFile + "'", e);
|
||||
throw new UnsupportedOperationException("Failed to write to file '" + path + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +50,11 @@ public final class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> readLinesFromFile(String file) {
|
||||
public static List<String> readLinesFromFile(Path path) {
|
||||
try {
|
||||
return Files.readAllLines(Paths.get(file), StandardCharsets.UTF_8);
|
||||
return Files.readAllLines(path, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
throw new UnsupportedOperationException("Could not read from file '" + file + "'", e);
|
||||
throw new UnsupportedOperationException("Could not read from file '" + path + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user