diff options
Diffstat (limited to 'src/main/java/at/knowcenter/wag')
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java | 6 | ||||
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java | 33 |
2 files changed, 35 insertions, 4 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java index eabff4d..676ef5c 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java @@ -47,6 +47,7 @@ import at.knowcenter.wag.egov.egiz.PdfAS; import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
import at.knowcenter.wag.egov.egiz.pdf.Utils;
+import at.knowcenter.wag.egov.egiz.tools.FileHelper;
/**
* The SettingsReader reads the <code>settings.txt</code> file. The
@@ -621,7 +622,8 @@ public class SettingsReader implements Serializable * @return null in case of error
*/
public String readInternalResourceAsString(String relativePath) {
- return readAsString(getInternalResource(relativePath));
+// return readAsString(getInternalResource(relativePath));
+ return FileHelper.readFromInputStream(getInternalResource(relativePath));
}
/**
@@ -651,6 +653,7 @@ public class SettingsReader implements Serializable * @param is
* @return <code>null</code> in case of error
*/
+ /*
public String readAsString(InputStream is) {
if (is == null) return null;
try {
@@ -660,6 +663,7 @@ public class SettingsReader implements Serializable }
return null;
}
+ */
// /**
// * This method checks the application context.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java index e72e52e..eb5e8c7 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java @@ -21,11 +21,13 @@ package at.knowcenter.wag.egov.egiz.tools; import java.io.BufferedReader;
import java.io.BufferedWriter;
-import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.FileReader;
import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import org.apache.log4j.Logger;
@@ -52,7 +54,7 @@ public class FileHelper { String file_string = null;
logger_.trace("Looking for file: " + fileName);
try {
- BufferedReader reader = new BufferedReader(new FileReader(fileName));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
logger_.trace("Reading file: " + fileName);
String line = null;
file_string = "";
@@ -70,6 +72,31 @@ public class FileHelper { }
/**
+ * This method reads a file by reading line by line.
+ *
+ * @param fileName the file to be read
+ * @return the content string of the file
+ */
+ public static String readFromInputStream(InputStream inputStream) {
+ String file_string = null;
+ if (inputStream == null) {
+ return null;
+ }
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
+ String line = null;
+ file_string = "";
+ while ((line = reader.readLine()) != null) {
+ file_string += line;
+ }
+ reader.close();
+ } catch (IOException e) {
+ logger_.debug("Error reading inputstream.");
+ }
+ return file_string;
+ }
+
+ /**
* This method writes a file line by line.
*
* @param fileName the file to be written
|