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:
ljacqu
2016-10-01 11:02:24 +02:00
parent 8d64c0e5bf
commit 113a3f346c
5 changed files with 31 additions and 34 deletions
+10 -5
View File
@@ -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);
}
}