diff --git a/src/fr/devinsy/util/ToolBox.java b/src/fr/devinsy/util/ToolBox.java index b2d749f..a090e33 100644 --- a/src/fr/devinsy/util/ToolBox.java +++ b/src/fr/devinsy/util/ToolBox.java @@ -270,6 +270,38 @@ public class ToolBox { String result; + result = loadToStringBuffer(file, charsetName).toString(); + + // + return result; + } + + /** + * + * @param file + * @return + * @throws IOException + */ + static public StringBuffer loadToStringBuffer(final File file) throws IOException + { + StringBuffer result; + + final String DEFAULT_CHARSET_NAME = "UTF-8"; + result = loadToStringBuffer(file, DEFAULT_CHARSET_NAME); + + // + return result; + } + + /** + * + * @param file + * @throws IOException + */ + public static StringBuffer loadToStringBuffer(final File file, final String charsetName) throws IOException + { + StringBuffer result; + BufferedReader in = null; try { @@ -277,7 +309,7 @@ public class ToolBox boolean ended = false; final String LINE_SEPARATOR = System.getProperty("line.separator"); - StringBuffer buffer = new StringBuffer((int) file.length()); + result = new StringBuffer((int) file.length()); while (!ended) { String line = in.readLine(); @@ -288,12 +320,9 @@ public class ToolBox } else { - buffer.append(line).append(LINE_SEPARATOR); + result.append(line).append(LINE_SEPARATOR); } } - - // - result = buffer.toString(); } finally {