Package io.deephaven.importers.util
Class SkipLinesInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
io.deephaven.importers.util.SkipLinesInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
CsvImporterHelperBpipe.BPipeInputStream
SkipLinesInputStream adds functionality to another InputStream namely the ability to skip header or footer lines. The
class maintains a queue of up to skip footer lines, popping a line on request only if there is more data to be read
in the input stream. The logic is only used if skip footer lines has a value greater than 0.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intFields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionSkipLinesInputStream(InputStream in, int skipHeaderLines, int skipFooterLines) Creates SkipLinesInputStream wrapper around given InputStream.SkipLinesInputStream(InputStream in, int skipHeaderLines, int skipFooterLines, int bufferSize) Creates SkipLinesInputStream wrapper around given InputStream using specified buffer size. -
Method Summary
Modifier and TypeMethodDescriptionintintstatic intintread()intread(byte @NotNull [] b, int off, int len) readLine()Returns the next available line from the stream as String.readLine(boolean ignoreLineBreakCharacters) If the ignoreLineBreakCharacters parameter is true the next available line will be returned without CR or LF or CRLF characters.protected voidreadLineAsBytes(gnu.trove.list.array.TByteArrayList line) Returns the next available line from the stream as bytes populated in TByteArrayList.voidreset()longskip(long n) Methods inherited from class java.io.BufferedInputStream
close, mark, markSupportedMethods inherited from class java.io.FilterInputStream
readMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
DEFAULT_BUFFER_SIZE
protected static final int DEFAULT_BUFFER_SIZE- See Also:
-
EOF
protected static final int EOF- See Also:
-
LINE_BUFFER_SIZE
protected static final int LINE_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
SkipLinesInputStream
public SkipLinesInputStream(InputStream in, int skipHeaderLines, int skipFooterLines) throws IOException Creates SkipLinesInputStream wrapper around given InputStream.- Parameters:
in- The underlying InputStreamskipHeaderLines- Number of lines to skip at the beginningskipFooterLines- Number of line to skip from end of stream- Throws:
IOException- from the underlying InputStream
-
SkipLinesInputStream
public SkipLinesInputStream(InputStream in, int skipHeaderLines, int skipFooterLines, int bufferSize) throws IOException Creates SkipLinesInputStream wrapper around given InputStream using specified buffer size.- Parameters:
in- The underlying InputStreamskipHeaderLines- Number of lines to skip at the beginningskipFooterLines- Number of line to skip from end of streambufferSize- BufferSize used by parent BufferedInputStream- Throws:
IOException- from the underlying InputStream
-
-
Method Details
-
getBufferSize
public int getBufferSize() -
getDefaultBufferSize
public static int getDefaultBufferSize() -
read
- Overrides:
readin classBufferedInputStream- Throws:
IOException
-
read
- Overrides:
readin classBufferedInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classBufferedInputStream- Throws:
IOException
-
available
- Overrides:
availablein classBufferedInputStream- Throws:
IOException
-
reset
- Overrides:
resetin classBufferedInputStream- Throws:
IOException
-
readLine
If the ignoreLineBreakCharacters parameter is true the next available line will be returned without CR or LF or CRLF characters. If ignoreLineBreakCharacters parameter is false returns the next available line from the stream as String. A line is determined by CR, LF or CRLF. In case of a CR the next byte is looked up and if it is LF then returned line includes up to LF, otherwise up to CR. The next byte is then the first byte to be read next.- Parameters:
ignoreLineBreakCharacters- indicates if the returned String should include the CR / LF or CRLF characters- Returns:
- the next line from the stream as String
- Throws:
IOException- from the underlying InputStream
-
readLine
Returns the next available line from the stream as String. A line is determined by CR, LF or CRLF. In case of a CR the next byte is looked up and if it is LF then returned line includes up to LF, otherwise up to CR. The next byte is then the first byte to be read next.- Returns:
- the next line
- Throws:
IOException- from the underlying InputStream
-
readLineAsBytes
Returns the next available line from the stream as bytes populated in TByteArrayList. A line is determined by CR, LF or CRLF. In case of a CR the next byte is looked up and if it is LF then returned line includes up to LF, otherwise up to CR. The next byte is then the first byte to be read next.- Parameters:
line- TByteArrayList that holds the byte array of the next line.- Throws:
IOException
-