Class CsvStreamReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    class CsvStreamReader
    extends au.com.bytecode.opencsv.CSVReader
    implements java.io.Closeable
    Extension to CSVReader that can read newly appended file content.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  CsvStreamReader.CsvContentListener
      Watches for content being appended to a CSV file.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Queue<java.lang.String> contentQueue  
      static long DEFAULT_MONITOR_DELAY
      The default file monitor delay.
      static int DEFAULT_SKIP_LINES
      The default line to start reading.
      protected au.com.bytecode.opencsv.CSVParser parser  
      protected int skipLines  
      protected org.apache.commons.io.input.Tailer tailer  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      (package private) CsvStreamReader​(Source source)  
      private CsvStreamReader​(Source source, char separator, char quoteChar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)
      Creates a CsvStreamReader with supplied separator and quote char.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the underlying reader.
      private java.lang.String getNextLine()
      Reads the next line from the file.
      java.lang.String[] readNext()
      Reads the next line from the buffer and converts to a string array.
      • Methods inherited from class au.com.bytecode.opencsv.CSVReader

        readAll
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • parser

        protected au.com.bytecode.opencsv.CSVParser parser
      • skipLines

        protected int skipLines
      • tailer

        protected org.apache.commons.io.input.Tailer tailer
      • contentQueue

        protected java.util.Queue<java.lang.String> contentQueue
      • DEFAULT_SKIP_LINES

        public static final int DEFAULT_SKIP_LINES
        The default line to start reading.
        See Also:
        Constant Field Values
      • DEFAULT_MONITOR_DELAY

        public static final long DEFAULT_MONITOR_DELAY
        The default file monitor delay.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CsvStreamReader

        CsvStreamReader​(Source source)
      • CsvStreamReader

        private CsvStreamReader​(Source source,
                                char separator,
                                char quoteChar,
                                char escape,
                                int line,
                                boolean strictQuotes,
                                boolean ignoreLeadingWhiteSpace)
        Creates a CsvStreamReader with supplied separator and quote char.
        Parameters:
        source - The file to an underlying CSV source
        separator - The delimiter to use for separating entries
        quoteChar - The character to use for quoted elements
        escape - The character to use for escaping a separator or quote
        line - The line number to skip for start reading
        strictQuotes - Sets if characters outside the quotes are ignored
        ignoreLeadingWhiteSpace - If true, parser should ignore white space before a quote in a field
    • Method Detail

      • readNext

        public java.lang.String[] readNext()
                                    throws java.io.IOException
        Reads the next line from the buffer and converts to a string array.
        Overrides:
        readNext in class au.com.bytecode.opencsv.CSVReader
        Returns:
        a string array with each comma-separated element as a separate entry.
        Throws:
        java.io.IOException - if bad things happen during the read
      • getNextLine

        private java.lang.String getNextLine()
                                      throws java.io.IOException
        Reads the next line from the file.
        Returns:
        the next line from the file without trailing newline
        Throws:
        java.io.IOException - if bad things happen during the read
      • close

        public void close()
                   throws java.io.IOException
        Closes the underlying reader.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class au.com.bytecode.opencsv.CSVReader
        Throws:
        java.io.IOException - if the close fails