Package org.deltafi.common.reader
Class BoundedLineReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
org.deltafi.common.reader.BoundedLineReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
Buffered reader that tracks the number of bytes read and bounds the
readLine method by the maxLineSize setting to limit the characters
read into memory.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBoundedLineReader(Reader in, int sz, long maxLineSize) BoundedLineReader(Reader in, long maxLineSize) -
Method Summary
Modifier and TypeMethodDescriptionlongCounts the number of bytes in the next line of text.readLine()Reads a line of text.voidsetMaxLineSize(long maxLineSize) Set the maxLineSize to a new valueMethods inherited from class java.io.BufferedReader
close, lines, mark, markSupported, read, read, ready, reset, skipMethods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Constructor Details
-
BoundedLineReader
-
BoundedLineReader
-
-
Method Details
-
countBytesInNextLine
Counts the number of bytes in the next line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a line feed, or by reaching the end-of-file (EOF).- Returns:
- the number of bytes in the next line of data including the terminating characters
- Throws:
IOException- If an I/O error occurs or the line is not terminated before reading the maximum number bytes as set bymaxLineSize
-
readLine
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a line feed, or by reaching the end-of-file (EOF).- Overrides:
readLinein classBufferedReader- Returns:
- A String containing the contents of the line, including any line-termination characters, or null if the end of the stream has been reached without reading any characters
- Throws:
IOException- If an I/O error occurs or the line is not terminated before reading the maximum number bytes as set bymaxLineSize
-
setMaxLineSize
public void setMaxLineSize(long maxLineSize) Set the maxLineSize to a new value- Parameters:
maxLineSize- new maxLineSize to use
-