Package htsjdk.tribble.readers
Class AsciiLineReader
- java.lang.Object
-
- htsjdk.tribble.readers.AsciiLineReader
-
- All Implemented Interfaces:
LocationAware,LineReader,Closeable,AutoCloseable
public class AsciiLineReader extends Object implements LineReader, LocationAware
A simple class that providesreadLine()functionality around a PositionalBufferedStreamBufferedReaderand itsBufferedReader.readLine()method should be used in preference to this class (when theLocationAwarefunctionality is not required) because it offers greater performance.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAsciiLineReader()AsciiLineReader(PositionalBufferedStream is)Deprecated.8/8/2017 usefrom(java.io.InputStream)AsciiLineReader(InputStream is)Deprecated.8/8/2017 usefrom(java.io.InputStream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()static AsciiLineReaderfrom(InputStream inputStream)Create an AsciiLineReader of the appropriate type for a given InputStream.intgetLineTerminatorLength()Returns the length of the line terminator read after the last read line.longgetPosition()The current offset, in bytes, of this stream/writer/file.StringreadLine()Same asreadLine(PositionalBufferedStream)but uses the stream provided in the constructorStringreadLine(PositionalBufferedStream stream)Deprecated.8/8/2017 usefrom(java.io.InputStream)to create a new AsciiLineReader andreadLine()StringtoString()
-
-
-
Constructor Detail
-
AsciiLineReader
protected AsciiLineReader()
-
AsciiLineReader
@Deprecated public AsciiLineReader(InputStream is)
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 public AsciiLineReader(PositionalBufferedStream is)
Deprecated.8/8/2017 usefrom(java.io.InputStream)- Parameters:
is- thePositionalBufferedStreaminput stream to be wrapped
-
-
Method Detail
-
from
public static AsciiLineReader from(InputStream inputStream)
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:LocationAwareThe 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:
getPositionin 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 public String readLine(PositionalBufferedStream stream) throws IOException
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
public String readLine() throws IOException
Same asreadLine(PositionalBufferedStream)but uses the stream provided in the constructor- Specified by:
readLinein interfaceLineReader- Returns:
- The next string, or null when input is exhausted.
- Throws:
IOException
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceLineReader
-
-