diff options
author | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-12-14 17:57:59 +0000 |
---|---|---|
committer | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-12-14 17:57:59 +0000 |
commit | d9d1dba18452e55a0801284570411bc4b1be279d (patch) | |
tree | 589ecc73b37ea76a85e357f12a9d86a37b1db201 /src/main/java/at | |
parent | a31c4170f5b09aefcc2d0cc9e5da7f415cc161d5 (diff) | |
download | pdf-as-3-d9d1dba18452e55a0801284570411bc4b1be279d.tar.gz pdf-as-3-d9d1dba18452e55a0801284570411bc4b1be279d.tar.bz2 pdf-as-3-d9d1dba18452e55a0801284570411bc4b1be279d.zip |
Reading templates line by line again
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@517 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at')
-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
|