Java Text File Write nio writeLine(final CharBuffer line, final CharBuffer output)

Here you can find the source of writeLine(final CharBuffer line, final CharBuffer output)

Description

Copies a non-header line to the output buffer.

License

Open Source License

Parameter

Parameter Description
line Line to consider writing.
output Output buffer.

Declaration

private static void writeLine(final CharBuffer line, final CharBuffer output) 

Method Source Code


//package com.java2s;
/* See LICENSE for licensing and NOTICE for copyright. */

import java.nio.CharBuffer;

public class Main {
    /** PEM encoding header start string. */
    public static final String HEADER_BEGIN = "-----BEGIN";
    /** PEM encoding footer start string. */
    public static final String FOOTER_END = "-----END";
    /** Procedure type tag for PEM-encoded private key in OpenSSL format. */
    public static final String PROC_TYPE = "Proc-Type:";
    /** Decryption infor tag for PEM-encoded private key in OpenSSL format. */
    public static final String DEK_INFO = "DEK-Info:";

    /**/*from   ww w . j a v a2  s.c o  m*/
     * Copies a non-header line to the output buffer.
     *
     * @param  line  Line to consider writing.
     * @param  output  Output buffer.
     */
    private static void writeLine(final CharBuffer line, final CharBuffer output) {
        final String s = line.flip().toString();
        if (!(s.startsWith(HEADER_BEGIN) || s.startsWith(FOOTER_END) || s.startsWith(PROC_TYPE)
                || s.startsWith(DEK_INFO) || s.trim().length() == 0)) {
            output.put(line);
        }
        line.clear();
    }
}

Related

  1. writeFileContent(File file, String content)
  2. writeFileContents(File file, String content)
  3. writeFileTxt(String fileName, String[] totalFile)
  4. writeHeader(DataOutput data, String header)
  5. writeIfSet(final OutputStream outputStream, final String field, final String value)
  6. writeLines(Collection lines, File file)
  7. writeLines(File file, Iterable lines)
  8. writeLines(String fileName, String[] lines)
  9. writeLinesToFile(final File file, final String... lines)