Class UnixPrintWriter

java.lang.Object
java.io.Writer
java.io.PrintWriter
org.pgcodekeeper.core.utils.UnixPrintWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class UnixPrintWriter extends PrintWriter
A PrintWriter implementation that ensures Unix-style line endings ('\n') regardless of the platform.
  • Constructor Details

    • UnixPrintWriter

      public UnixPrintWriter(Writer out)
      Creates a new UnixPrintWriter without automatic line flushing.
      Parameters:
      out - the underlying writer
    • UnixPrintWriter

      public UnixPrintWriter(OutputStream out)
      Creates a new UnixPrintWriter from an OutputStream.
      Parameters:
      out - the underlying output stream
    • UnixPrintWriter

      public UnixPrintWriter(String fileName) throws FileNotFoundException
      Creates a new UnixPrintWriter that writes to a file.
      Parameters:
      fileName - path to the output file
      Throws:
      FileNotFoundException - if the file cannot be opened
    • UnixPrintWriter

      public UnixPrintWriter(File file) throws FileNotFoundException
      Creates a new UnixPrintWriter that writes to a file.
      Parameters:
      file - the output file
      Throws:
      FileNotFoundException - if the file cannot be opened
    • UnixPrintWriter

      public UnixPrintWriter(Writer out, boolean autoFlush)
      Creates a new UnixPrintWriter with optional auto-flush.
      Parameters:
      out - the underlying writer
      autoFlush - if true, flushes after every println call
    • UnixPrintWriter

      public UnixPrintWriter(OutputStream out, boolean autoFlush)
      Creates a new UnixPrintWriter from an OutputStream with optional auto-flush.
      Parameters:
      out - the underlying output stream
      autoFlush - if true, flushes after every println call
    • UnixPrintWriter

      public UnixPrintWriter(String fileName, String csn) throws FileNotFoundException, UnsupportedEncodingException
      Creates a new UnixPrintWriter that writes to a file with specified charset.
      Parameters:
      fileName - path to the output file
      csn - charset name for encoding
      Throws:
      FileNotFoundException - if the file cannot be opened
      UnsupportedEncodingException - if the charset is not supported
    • UnixPrintWriter

      public UnixPrintWriter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException
      Creates a new UnixPrintWriter that writes to a file with specified charset.
      Parameters:
      file - the output file
      csn - charset name for encoding
      Throws:
      FileNotFoundException - if the file cannot be opened
      UnsupportedEncodingException - if the charset is not supported
    • UnixPrintWriter

      public UnixPrintWriter(OutputStream out, String csn) throws UnsupportedEncodingException
      Creates a new UnixPrintWriter from an OutputStream with specified charset.
      Parameters:
      out - the underlying output stream
      csn - charset name for encoding
      Throws:
      UnsupportedEncodingException - if the charset is not supported
    • UnixPrintWriter

      public UnixPrintWriter(String fileName, Charset csn) throws FileNotFoundException
      Creates a new UnixPrintWriter that writes to a file with specified charset.
      Parameters:
      fileName - path to the output file
      csn - charset for encoding
      Throws:
      FileNotFoundException - if the file cannot be opened
    • UnixPrintWriter

      public UnixPrintWriter(File file, Charset csn) throws FileNotFoundException
      Creates a new UnixPrintWriter that writes to a file with specified charset.
      Parameters:
      file - the output file
      csn - charset for encoding
      Throws:
      FileNotFoundException - if the file cannot be opened
  • Method Details

    • println

      public void println()


      This version always terminates with '\n'.
      Overrides:
      println in class PrintWriter