RTEditor/src/main/java/com/onegravity/rteditor/utils/io/IOUtils.java
public static void writeLines(Collection<?> lines, String lineEnding, OutputStream output, Charset encoding)
            throws IOException {
        if (lines == null) {
            return;
        }
        if (lineEnding == null) {
            lineEnding = LINE_SEPARATOR;
        }
        Charset cs = Charsets.toCharset(encoding);
        for (Object line : lines) {
            if (line != null) {
                output.write(line.toString().getBytes(cs));
            }
            output.write(lineEnding.getBytes(cs));
        }
    }
public static void writeLines(Collection<?> lines, String lineEnding, OutputStream output, Charset encoding)
            throws IOException {
        if (lines == null) {
            return;
        }
        if (lineEnding == null) {
            lineEnding = LINE_SEPARATOR;
        }
        Charset cs = Charsets.toCharset(encoding);
        for (Object line : lines) {
            if (line != null) {
                output.write(line.toString().getBytes(cs));
            }
            output.write(lineEnding.getBytes(cs));
        }
    }
public static void writeLines ( Collection < ? > lines , String lineEnding , OutputStream output , Charset encoding ) throws IOException { if ( lines == null ) { return ; } if ( lineEnding == null ) { lineEnding = LINE_SEPARATOR ; } Charset cs = Charsets . toCharset ( encoding ) ; for ( Object line : lines ) { if ( line != null ) { output . write ( line . toString ( ) . getBytes ( cs ) ) ; } output . write ( lineEnding . getBytes ( cs ) ) ; } }
Writes the <code>toString()</code> value of each item in a collection to
an <code>OutputStream</code> line by line, using the specified character
encoding and the specified line ending.

@param lines      the lines to write, null entries produce blank lines
@param lineEnding the line separator to use, null is system default
@param output     the <code>OutputStream</code> to write to, not null, not closed
@param encoding   the encoding to use, null means platform default
@throws NullPointerException if the output is null
@throws IOException          if an I/O error occurs
@since 2.3
Writes the <code > toString () < / code > value of each item in a collection to an <code > OutputStream< / code > line by line using the specified character encoding and the specified line ending .