Package util

Class TableWriter

java.lang.Object
util.TableWriter

public class TableWriter extends Object
Class for writers for files with tabular data.
Since:
2007.05.20
  • Constructor Details

    • TableWriter

      public TableWriter(Writer writer)
      Create a table writer with default characters.
      Parameters:
      writer - the writer to work on
      Since:
      2007.05.20 (Christian Borgelt)
    • TableWriter

      public TableWriter(OutputStream stream) throws IOException
      Create a table writer with default characters.
      Parameters:
      stream - the output stream to write on
      Throws:
      IOException - if a read error occurs
      Since:
      2007.05.20 (Christian Borgelt)
  • Method Details

    • setRecSep

      public final void setRecSep(int recsep)
      Set the record separator.
      Parameters:
      recsep - the record separator
      Since:
      2007.05.20 (Christian Borgelt)
    • setFldSep

      public final void setFldSep(int fldsep)
      Set the field separator.
      Parameters:
      fldsep - the field separator
      Since:
      2007.05.20 (Christian Borgelt)
    • setBlank

      public final void setBlank(int blank)
      Set the blank character.
      Parameters:
      blank - the blank character
      Since:
      2007.05.20 (Christian Borgelt)
    • setNullChar

      public final void setNullChar(int nullch)
      Set the null value character.
      Parameters:
      nullch - the null value character
      Since:
      2007.05.20 (Christian Borgelt)
    • setChars

      public final void setChars(String seps)
      Set all separator characters.
      Parameters:
      seps - the separators to use for writing
      char 0: record separator
      char 1: field separator
      char 2: blank character (optional)
      char 3: null value character (optional)
      Since:
      2007.05.20 (Christian Borgelt)
    • setCharsCoded

      public final void setCharsCoded(String seps)
      Set all separator characters.
      Parameters:
      seps - the separators to use for writing
      Since:
      2007.05.20 (Christian Borgelt)
    • write

      public final void write(String s) throws IOException
      Write a field.
      Parameters:
      s - the contents of the field to write
      Throws:
      IOException - if an I/O error occurs
      Since:
      2007.05.20 (Christian Borgelt)
    • write

      public final void write(String s, int width) throws IOException
      Write a field.
      Parameters:
      s - the contents of the field to write
      width - the width to which to fill the field
      Throws:
      IOException - if an I/O error occurs
      Since:
      2007.05.20 (Christian Borgelt)
    • write

      public final void write(String s, boolean last) throws IOException
      Write a field.
      Parameters:
      s - the contents of the field to write
      last - whether this is the last field of a record
      Throws:
      IOException - if an I/O error occurs
      Since:
      2007.05.20 (Christian Borgelt)
    • write

      public final void write(String s, int width, boolean last) throws IOException
      Write a field.
      Parameters:
      s - the contents of the field to write
      width - the width to which to fill the field
      last - whether this is the last field of a record
      Throws:
      IOException - if an I/O error occurs
      Since:
      2007.05.20 (Christian Borgelt)
    • writeLast

      public final void writeLast(String s) throws IOException
      Write the last field of a record.
      Parameters:
      s - the contents of the field to write
      Throws:
      IOException - if an I/O error occurs
      Since:
      2007.05.20 (Christian Borgelt)
    • writeLast

      public final void writeLast(String s, int width) throws IOException
      Write the last field of a record.
      Parameters:
      s - the contents of the field to write
      width - the width to which to fill the field
      Throws:
      IOException - if an I/O error occurs
      Since:
      2007.05.20 (Christian Borgelt)
    • close

      public final void close() throws IOException
      Close the underlying stream.
      Throws:
      IOException - if an I/O error occurs
      Since:
      2007.05.20 (Christian Borgelt)