diff --git a/src/fr/devinsy/strings/StringsUtils.java b/src/fr/devinsy/strings/StringsUtils.java index f752f58..7b41537 100644 --- a/src/fr/devinsy/strings/StringsUtils.java +++ b/src/fr/devinsy/strings/StringsUtils.java @@ -1150,8 +1150,8 @@ public class StringsUtils } /** - * Save. - * + * Save string of the list as lines. + * * @param file * the file * @param source @@ -2181,7 +2181,7 @@ public class StringsUtils * @throws IOException * Signals that an I/O exception has occurred. */ - public static void writeTo(final StringList source, final java.io.PrintWriter out) throws IOException + public static void writeTo(final java.io.PrintWriter out, final StringList source) throws IOException { if (source != null) { @@ -2202,7 +2202,7 @@ public class StringsUtils * @throws IOException * Signals that an I/O exception has occurred. */ - public static void writeTo(final StringList source, final java.io.Writer out) throws IOException + public static void writeTo(final java.io.Writer out, final StringList source) throws IOException { if (source != null) { @@ -2212,4 +2212,40 @@ public class StringsUtils } } } + + /** + * Save. + * + * @param file + * the file + * @param source + * the source + * @throws UnsupportedEncodingException + * the unsupported encoding exception + * @throws FileNotFoundException + * the file not found exception + */ + public static void writeToFile(final File file, final StringList source) throws UnsupportedEncodingException, FileNotFoundException + { + PrintWriter out = null; + try + { + out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), DEFAULT_CHARSET_NAME)); + + if (source != null) + { + for (String string : source) + { + out.print(string); + } + } + } + finally + { + if (out != null) + { + out.close(); + } + } + } }