Class CsvPrintWriter

java.lang.Object
java.io.Writer
java.io.PrintWriter
overit.geocall.util.CsvPrintWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class CsvPrintWriter extends PrintWriter
Utility class that extends PrintWriter and it's used to manage the CSV Print Writer that prints formatted representations of objects to a text-output stream.
  • Field Details

    • _sep

      protected char _sep
    • _quote

      protected char _quote
    • _alwaysQuote

      protected boolean _alwaysQuote
    • _lineSeparator

      protected String _lineSeparator
  • Constructor Details

    • CsvPrintWriter

      public CsvPrintWriter(Writer w)
      Creates a new CsvPrintWriter, without automatic line flushing.
      Parameters:
      w - A character-output stream
    • CsvPrintWriter

      public CsvPrintWriter(Writer w, boolean af)
      Creates a new CsvPrintWriter.
      Parameters:
      w - A character-output stream
      af - A boolean; if true, the println, printf, or format methods will flush the output buffer
    • CsvPrintWriter

      public CsvPrintWriter(OutputStream os)
      Creates a new CsvPrintWriter, without automatic line flushing, from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.
      Parameters:
      os - An output stream
      See Also:
    • CsvPrintWriter

      public CsvPrintWriter(OutputStream os, boolean af)
      Creates a new CsvPrintWriter from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.
      Parameters:
      os - An output stream
      af - A boolean; if true, the println, printf, or format methods will flush the output buffer
      See Also:
  • Method Details

    • alwaysQuote

      public void alwaysQuote(boolean aq)
      Sets the always quote flag
      Parameters:
      aq - Boolean indicating if always quote should be enabled or not
    • setSeparator

      public void setSeparator(char c)
      Sets the separator
      Parameters:
      c - The separator
    • setQuote

      public void setQuote(char c)
      Sets the quote
      Parameters:
      c - The quote
    • setLineSeparator

      public void setLineSeparator(String s)
      Sets the line separator
      Parameters:
      s - The line separator
    • printField

      protected void printField(String s, boolean hasNext)
    • printlnCsv

      public void printlnCsv(List al) throws IOException
      Print the CSV
      Parameters:
      al - The list
      Throws:
      IOException - if an I/O error occurs
    • printlnCsv

      public void printlnCsv(String[] list) throws IOException
      Print the CSV
      Parameters:
      list - The array
      Throws:
      IOException - if an I/O error occurs
    • main

      public static void main(String[] ss) throws Exception
      Throws:
      Exception