Improved writeTo utils methods.
This commit is contained in:
parent
905a808aaa
commit
565af32f0b
1 changed files with 40 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue