[Lada-commits] [PATCH 1 of 2] Fixed encoding problem for query configuration

Wald Commits scm-commit at wald.intevation.org
Wed Nov 25 13:35:10 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1448454879 -3600
# Node ID a549700c338d32aa4260ec0158fc9d3593d78f5f
# Parent  183396bac3face6c3385079a86ec0f5dc6d92b07
Fixed encoding problem for query configuration.

diff -r 183396bac3fa -r a549700c338d src/main/java/de/intevation/lada/query/QueryTools.java
--- a/src/main/java/de/intevation/lada/query/QueryTools.java	Thu Nov 19 16:55:32 2015 +0100
+++ b/src/main/java/de/intevation/lada/query/QueryTools.java	Wed Nov 25 13:34:39 2015 +0100
@@ -14,6 +14,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Scanner;
 
 import javax.json.Json;
 import javax.json.JsonArray;
@@ -43,14 +44,13 @@
     public static String readConfigFile(String file) {
         try {
             InputStream inputStream = QueryConfig.class.getResourceAsStream(file);
-            int ch;
-            StringBuilder builder = new StringBuilder();
-            while((ch = inputStream.read()) != -1) {
-                builder.append((char)ch);
-            }
-            return builder.toString();
+            Scanner scanner = new Scanner(inputStream, "UTF-8");
+            scanner.useDelimiter("\\A");
+            String configString = scanner.next();
+            scanner.close();
+            return configString;
         }
-        catch (IOException ioe) {
+        catch (Exception ioe) {
             ioe.printStackTrace();
             return null;
         }


More information about the Lada-commits mailing list