|
|
@@ -10,7 +10,9 @@ package net.ranides.assira.io;
|
|
|
import java.io.*;
|
|
|
import java.security.AccessController;
|
|
|
import java.security.PrivilegedAction;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
import java.util.MissingResourceException;
|
|
|
import java.util.Scanner;
|
|
|
import net.ranides.assira.generic.ValueUtils;
|
|
|
@@ -68,6 +70,37 @@ public final class FileHelper {
|
|
|
public static byte[] getFileContent(String file) throws IOException {
|
|
|
return getFileContent(new File(file));
|
|
|
}
|
|
|
+
|
|
|
+ public static List<String> getFileText(File file, String charset) throws IOException {
|
|
|
+ FileInputStream istream = null;
|
|
|
+ BufferedReader reader = null;
|
|
|
+ ArrayList<String> result = new ArrayList<String>();
|
|
|
+ try {
|
|
|
+ istream = new FileInputStream(file);
|
|
|
+ reader = new BufferedReader(new InputStreamReader(istream, charset));
|
|
|
+ String line;
|
|
|
+ while( null != (line=reader.readLine())) {
|
|
|
+ result.add(line);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ FileHelper.close(reader);
|
|
|
+ FileHelper.close(istream);
|
|
|
+ }
|
|
|
+ result.trimToSize();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<String> getFileText(String file, String charset) throws IOException {
|
|
|
+ return getFileText(new File(file), charset);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<String> getFileText(File file) throws IOException {
|
|
|
+ return getFileText(file, "UTF-8");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<String> getFileText(String file) throws IOException {
|
|
|
+ return getFileText(file, "UTF-8");
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Ładuje zawartość podanego pliku i zwraca w postaci tekstu.
|