Package csv.impl

Class AbstractStreamTableReader

java.lang.Object
csv.impl.AbstractTableReader
csv.impl.AbstractStreamTableReader
All Implemented Interfaces:
TableReader, Iterable<Object[]>, Iterator<Object[]>
Direct Known Subclasses:
CSVReader, ExcelReader, XmlReader

public abstract class AbstractStreamTableReader extends AbstractTableReader
An abstract implementation of TableReader. This implementation takes care of simple stream handling.
Author:
RalphSchuster
  • Constructor Details

    • AbstractStreamTableReader

      public AbstractStreamTableReader()
      Default Constructor.
    • AbstractStreamTableReader

      public AbstractStreamTableReader(InputStream in)
      The constructor for a given input stream.
      Parameters:
      in - input stream
    • AbstractStreamTableReader

      public AbstractStreamTableReader(File file) throws FileNotFoundException
      Creates a new instance of Reader.
      Parameters:
      file - file to read from
      Throws:
      FileNotFoundException - when the file could not be found.
    • AbstractStreamTableReader

      public AbstractStreamTableReader(String file) throws FileNotFoundException
      Creates a new instance of Reader.
      Parameters:
      file - file to read from
      Throws:
      FileNotFoundException - when the file could not be found.
  • Method Details

    • setInputStream

      public void setInputStream(InputStream in)
      Sets the input stream. This implementation throws an exception when the stream is already set.
      Parameters:
      in - the stream to set
    • getReader

      protected BufferedReader getReader()
      Returns the underlying reader.
      Returns:
      reader object
    • createReader

      protected BufferedReader createReader()
      Creates the buffered reader. The method will call createInputStreamReader(InputStream) for the creation of the underlying reader.
      Returns:
      the buffered reader.
    • createInputStreamReader

      protected InputStreamReader createInputStreamReader(InputStream stream)
      Creates the input stream reader that feeds the buffered reader.
      Parameters:
      stream - the original input stream
      Returns:
      the stream reader
    • getCharsetDecoder

      public CharsetDecoder getCharsetDecoder()
      Returns the charset decoder to be used.
      Returns:
      the charset decoder
    • setCharsetDecoder

      public void setCharsetDecoder(CharsetDecoder charsetDecoder)
      Sets the charset decoder to be used on the input stream.
      Parameters:
      charsetDecoder - the charset decoder to set
    • setCharset

      public void setCharset(Charset charset)
      Sets the charset to be used on the input stream.
      Parameters:
      charset - the charset to set
    • setCharset

      public void setCharset(String charset)
      Sets the charset to be used on the input stream.
      Parameters:
      charset - the charset to set
    • getInputStream

      public InputStream getInputStream()
      Returns the underlying input stream.
      Returns:
      the inputStream
    • reset

      public void reset()
      Resets the reader and its underlying stream.
      Specified by:
      reset in interface TableReader
      Overrides:
      reset in class AbstractTableReader
    • remove

      public void remove()
      This method throws an exception. Input streams cannot support the remove method.
    • close

      public void close()
      Closes the reader and its underlying stream.
      Specified by:
      close in interface TableReader
      Overrides:
      close in class AbstractTableReader
      See Also: