Class CommentReader


  • public class CommentReader
    extends java.lang.Object
    Skips commented lines read from an input stream. The input stream must support marking (i.e. Reader.markSupported() must return true). A line is considered commented if it starts with one of the configured comment indicators.
    Since:
    1.2
    • Constructor Summary

      Constructors 
      Constructor Description
      CommentReader​(java.io.Reader in, java.lang.String[] comments)
      Constructs a new CommentReader.
      CommentReader​(java.io.Reader in, java.lang.String[] comments, java.lang.Character recordTerminator)
      Constructs a new CommentReader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isEOF()
      Returns whether the end of the stream was reached reading a commented line.
      boolean isSkipLF()
      Returns whether the next character should be ignored if its a line feed.
      int skipComments​(boolean initialSkipLF)
      Skips comments in the input stream and returns the number of commented lines read.
      • Methods inherited from class java.lang.Object

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

      • CommentReader

        public CommentReader​(java.io.Reader in,
                             java.lang.String[] comments)
                      throws java.lang.IllegalArgumentException
        Constructs a new CommentReader.
        Parameters:
        in - the input stream to read
        comments - an array of comment identifying strings
        Throws:
        java.lang.IllegalArgumentException - if the configured comments are invalid or the reader does not support marking
      • CommentReader

        public CommentReader​(java.io.Reader in,
                             java.lang.String[] comments,
                             java.lang.Character recordTerminator)
                      throws java.lang.IllegalArgumentException
        Constructs a new CommentReader.
        Parameters:
        in - the input stream to read from
        comments - an array of comment identifying strings
        recordTerminator - the record terminating character
        Throws:
        java.lang.IllegalArgumentException - if the configured comments are invalid or the reader does not support marking
    • Method Detail

      • isSkipLF

        public boolean isSkipLF()
        Returns whether the next character should be ignored if its a line feed.
        Returns:
        true if the next line feed should be ignored
      • isEOF

        public boolean isEOF()
        Returns whether the end of the stream was reached reading a commented line.
        Returns:
        true if the end of the stream was reached reading a commented line.
      • skipComments

        public int skipComments​(boolean initialSkipLF)
                         throws java.io.IOException
        Skips comments in the input stream and returns the number of commented lines read. If no commented lines were read, the stream is positioned just as it had been before this method is called.
        Parameters:
        initialSkipLF - true if the first line feed character read should be ignored
        Returns:
        the number of skipped comment lines
        Throws:
        java.io.IOException