Package org.beanio.stream.util
Class CommentReader
- java.lang.Object
-
- org.beanio.stream.util.CommentReader
-
public class CommentReader extends java.lang.ObjectSkips commented lines read from an input stream. The input stream must support marking (i.e.Reader.markSupported()must returntrue). 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 newCommentReader.CommentReader(java.io.Reader in, java.lang.String[] comments, java.lang.Character recordTerminator)Constructs a newCommentReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisEOF()Returns whether the end of the stream was reached reading a commented line.booleanisSkipLF()Returns whether the next character should be ignored if its a line feed.intskipComments(boolean initialSkipLF)Skips comments in the input stream and returns the number of commented lines read.
-
-
-
Constructor Detail
-
CommentReader
public CommentReader(java.io.Reader in, java.lang.String[] comments) throws java.lang.IllegalArgumentExceptionConstructs a newCommentReader.- Parameters:
in- the input stream to readcomments- 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.IllegalArgumentExceptionConstructs a newCommentReader.- Parameters:
in- the input stream to read fromcomments- an array of comment identifying stringsrecordTerminator- 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:
trueif 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:
trueif the end of the stream was reached reading a commented line.
-
skipComments
public int skipComments(boolean initialSkipLF) throws java.io.IOExceptionSkips 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-trueif the first line feed character read should be ignored- Returns:
- the number of skipped comment lines
- Throws:
java.io.IOException
-
-