Class TablePrinter

java.lang.Object
fc.io.TablePrinter

public class TablePrinter extends Object
Prints a table formatted using plain text/ascii characters. Useful for console based output and/or formatted output to a file.
  • Constructor Details

    • TablePrinter

      public TablePrinter(int columnCount, PrintStream ps, TablePrinter.PrintConfig config)
      Constructs a new table printer.
      Parameters:
      columnCount - the number of columns in the table. Attemps to print more than these number of columns will result in a runtime exception.
      config - the printing configuration
      pw - the destination print stream
    • TablePrinter

      public TablePrinter(int columnCount, PrintWriter pw, TablePrinter.PrintConfig config)
      Constructs a new table printer.
      Parameters:
      columnCount - the number of columns in the table. Attemps to print more than these number of columns will result in a runtime exception.
      pw - the destination print writer
      config - the printing configuration
  • Method Details

    • startTable

      public void startTable()
      This method should be called to start the table
    • endTable

      public void endTable()
      This method should be called to finish the table
    • startRow

      public void startRow()
      This method should be called to start a new row
    • endRow

      public void endRow()
      This method should be called to finish the existing row
    • printCell

      public void printCell(String str)
      This method should be called to print a new cell in the current row. This method should not be invoked for more columns than the table was instantiated with, otherwise a runtime exception will be thrown.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • main

      public static void main(String[] args)