Package htsjdk.tribble.readers
Class AsciiLineReader
java.lang.Object
htsjdk.tribble.readers.AsciiLineReader
- All Implemented Interfaces:
LocationAware
,LineReader
,Closeable
,AutoCloseable
A simple class that provides
readLine()
functionality around a PositionalBufferedStream
BufferedReader
and its BufferedReader.readLine()
method should be used in preference to this class (when the
LocationAware
functionality is not required) because it offers greater performance.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Deprecated.Deprecated.8/8/2017 usefrom(java.io.InputStream)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static AsciiLineReader
from
(InputStream inputStream) Create an AsciiLineReader of the appropriate type for a given InputStream.int
Returns the length of the line terminator read after the last read line.long
The current offset, in bytes, of this stream/writer/file.readLine()
Same asreadLine(PositionalBufferedStream)
but uses the stream provided in the constructorreadLine
(PositionalBufferedStream stream) Deprecated.8/8/2017 usefrom(java.io.InputStream)
to create a new AsciiLineReader andreadLine()
toString()
-
Constructor Details
-
AsciiLineReader
protected AsciiLineReader() -
AsciiLineReader
Deprecated.8/8/2017 usefrom(java.io.InputStream)
Note: This class implements LocationAware, which requires preservation of virtual file pointers on BGZF inputs. However, if the inputStream wrapped by this class is a BlockCompressedInputStream, it violates that contract by wrapping the stream and returning positional file offsets instead. -
AsciiLineReader
Deprecated.8/8/2017 usefrom(java.io.InputStream)
- Parameters:
is
- thePositionalBufferedStream
input stream to be wrapped
-
-
Method Details
-
from
Create an AsciiLineReader of the appropriate type for a given InputStream.- Parameters:
inputStream
- An InputStream-derived class that implements BlockCompressedInputStream or PositionalBufferedStream- Returns:
- AsciiLineReader that wraps inputStream
-
getPosition
public long getPosition()Description copied from interface:LocationAware
The current offset, in bytes, of this stream/writer/file. Or, if this is an iterator/producer, the offset (in bytes) of the END of the most recently returned record (since a produced record corresponds to something that has been read already). See class javadoc for more. Note that for BGZF files, this does not represent an actually file position, but a virtual file pointer.- Specified by:
getPosition
in interfaceLocationAware
- Returns:
- The position of the InputStream
-
getLineTerminatorLength
public int getLineTerminatorLength()Returns the length of the line terminator read after the last read line. Returns either: -1 if no line has been read 0 after the last line if the last line in the file had no CR or LF line ending 1 if the line ended with CR or LF 2 if the line ended with CR and LF -
readLine
Deprecated.8/8/2017 usefrom(java.io.InputStream)
to create a new AsciiLineReader andreadLine()
Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.- Parameters:
stream
- the stream to read the next line from- Returns:
- A String containing the contents of the line or null if the end of the stream has been reached
- Throws:
IOException
-
readLine
Same asreadLine(PositionalBufferedStream)
but uses the stream provided in the constructor- Specified by:
readLine
in interfaceLineReader
- Returns:
- The next string, or null when input is exhausted.
- Throws:
IOException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceLineReader
-
toString
-
from(java.io.InputStream)