X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fcom%2Fdogcows%2FUtil.java;h=412ef4a95b2e24258ec137777cb7bbfe3e058048;hb=c4d7e0da9accfe7aed04c768892b08e18ad085fd;hp=47fdd20d1cdef9c51d0d23ad90c7e0702ba59ab1;hpb=28c8fae03b2294d6486233cd62f4d4d9d11603ca;p=chaz%2Fvimcoder diff --git a/src/com/dogcows/Util.java b/src/com/dogcows/Util.java index 47fdd20..412ef4a 100644 --- a/src/com/dogcows/Util.java +++ b/src/com/dogcows/Util.java @@ -61,12 +61,12 @@ public abstract class Util } /** - * Quote a string by replacing prepending backslashes and double + * Escape a string by replacing prepending backslashes and double * quotation characters with an extra backslash. - * @param The string to be quoted. - * @return The quoted string. + * @param The string to be escaped. + * @return The escaped string. */ - public static String quote(String a) + public static String escape(String a) { a = a.replaceAll("\\\\", "\\\\\\\\"); a = a.replaceAll("\"", "\\\\\\\""); @@ -98,7 +98,7 @@ public abstract class Util reader.close(); } - return text.toString(); + return text.toString().replaceAll("\n", System.getProperty("line.separator")); } /** @@ -120,7 +120,7 @@ public abstract class Util try { byte[] buffer = new byte[4096]; - int numBytes = 0; + int numBytes = 0; while (0 < (numBytes = stream.read(buffer))) { text.append(new String(buffer, 0, numBytes)); @@ -132,7 +132,7 @@ public abstract class Util } } - return text.toString(); + return text.toString().replaceAll("\n", System.getProperty("line.separator")); } /** @@ -151,8 +151,7 @@ public abstract class Util String text = template; for (String key : terms.keySet()) { - text = text.replaceAll("\\$" + key + "\\$", - Util.quote(terms.get(key))); + text = text.replaceAll("\\$" + key + "\\$", Util.escape(terms.get(key))); } return text; }