Package org.beanio.stream.util
Class CommentReader
- java.lang.Object
-
- org.beanio.stream.util.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 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 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.
-
-
-
Constructor Detail
-
CommentReader
public CommentReader(java.io.Reader in, java.lang.String[] comments) throws java.lang.IllegalArgumentException
Constructs 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.IllegalArgumentException
Constructs 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:
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
-
-