Class TableWriter

java.lang.Object
gov.nasa.pds.objectAccess.TableWriter

public class TableWriter extends Object
The TableWriter class is used for writing fixed-width text, fixed-width binary and delimited data files.
  • Constructor Details

    • TableWriter

      public TableWriter(Object table, OutputStream outputStream, String charsetName) throws UnsupportedCharsetException, InvalidTableException
      Creates an instance of TableWriter for writing to a fixed-width text or binary data file. For fixed-width text file, 'carriage return + line feed' is used for record delimiter.
      Parameters:
      table - a table object
      outputStream - an output stream
      charsetName - the charset name to use for encoding the bytes.
      Throws:
      UnsupportedCharsetException
      InvalidTableException
    • TableWriter

      public TableWriter(Object table, OutputStream outputStream) throws InvalidTableException
      Creates an instance of TableWriter for writing to a fixed-width text or binary data file and uses "US-ASCII" character set name for encoding. For fixed-width text file, 'carriage return + line feed' is used for record delimiter.
      Parameters:
      table - a table object
      outputStream - an output stream
      Throws:
      InvalidTableException
    • TableWriter

      public TableWriter(Object table, Writer writer) throws InvalidTableException
      Creates an instance of TableWriter for writing to a delimited data file. It uses 'carriage return + line feed' for record delimiter.
      Parameters:
      table - a table object
      writer - a writer object
      Throws:
      InvalidTableException
  • Method Details

    • createRecord

      public TableRecord createRecord()
      Creates a record for adding data.
      Returns:
      an instance of TableRecord
    • write

      public void write(TableRecord record) throws IOException
      Writes the table record to the output stream or writer.
      Parameters:
      record - the TableRecord object
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      Flushes the output stream or writer.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Closes this table writer which may no longer be used for writing records.
      Throws:
      IOException