mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 08:18:52 -05:00
* added function readLines(String path) to scripting context
This commit is contained in:
parent
2334a9fcba
commit
ae97adb814
@ -4,6 +4,7 @@ import groovy.lang.Closure;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
@ -90,7 +91,7 @@ public class ExpressionFormatFunctions {
|
||||
|
||||
public static Map<String, String> csv(String path) throws IOException {
|
||||
Map<String, String> map = new LinkedHashMap<String, String>();
|
||||
for (String line : Files.readAllLines(Paths.get(path), Charset.forName("UTF-8"))) {
|
||||
for (String line : Files.readAllLines(Paths.get(path), StandardCharsets.UTF_8)) {
|
||||
for (String delim : new String[] { "\t", ";" }) {
|
||||
String[] field = line.split(delim, 2);
|
||||
if (field.length >= 2) {
|
||||
@ -102,4 +103,8 @@ public class ExpressionFormatFunctions {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static List<String> readLines(String path) throws IOException {
|
||||
return Files.readAllLines(Paths.get(path), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user