Add version parameter

This commit is contained in:
2022-04-19 21:03:14 +02:00
parent a606c50637
commit bfb6cab62c
6 changed files with 38 additions and 13 deletions

View File

@@ -3,11 +3,8 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.util;
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.ConfigErrors;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -17,18 +14,14 @@ public class LanguageValidatorUtil {
static {
try {
ISO3_LANGUAGES = load("language-codes");
ISO3_LANGUAGES = loadLanguageCodes();
} catch (IOException ignored) {}
}
private static Set<String> load(String path) throws IOException{
if (new File(path).isFile()) {
return Files.lines(Path.of(path)).collect(Collectors.toSet());
} else {
try(BufferedReader bf = new BufferedReader(new InputStreamReader(
Objects.requireNonNull(LanguageValidatorUtil.class.getClassLoader().getResourceAsStream(path))))) {
return bf.lines().collect(Collectors.toSet());
}
private static Set<String> loadLanguageCodes() throws IOException {
try (BufferedReader bf = new BufferedReader(new InputStreamReader(
Objects.requireNonNull(LanguageValidatorUtil.class.getClassLoader().getResourceAsStream("language-codes"))))) {
return bf.lines().collect(Collectors.toSet());
}
}