# 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 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

Constructors
Modifier
Constructor
Description
`protected`
`AsciiLineReader()`
``
`AsciiLineReader(PositionalBufferedStream is)`
Deprecated.
8/8/2017 use `from(InputStream)`
``
`AsciiLineReader(InputStream is)`
Deprecated.
8/8/2017 use `from(InputStream)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`static AsciiLineReader`
`from(InputStream inputStream)`
Create an AsciiLineReader of the appropriate type for a given InputStream.
`int`
`getLineTerminatorLength()`
Returns the length of the line terminator read after the last read line.
`long`
`getPosition()`
The current offset, in bytes, of this stream/writer/file.
`String`
`readLine()`
Same as `readLine(PositionalBufferedStream)` but uses the stream provided in the constructor
`String`
`readLine(PositionalBufferedStream stream)`
Deprecated.
8/8/2017 use `from(InputStream)` to create a new AsciiLineReader and `readLine()`
`String`
`toString()`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### AsciiLineReader

protected AsciiLineReader()

### AsciiLineReader

@Deprecated public AsciiLineReader(InputStream is)
Deprecated.
8/8/2017 use `from(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 use `from(InputStream)`

Parameters:
  `is` - the `PositionalBufferedStream` input stream to be wrapped

## Method Details

### 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: `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 interface `LocationAware`
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 use `from(InputStream)` to create a new AsciiLineReader and `readLine()`
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 as `readLine(PositionalBufferedStream)` but uses the stream provided in the constructor

Specified by:
  `readLine` in interface `LineReader`
Returns:
  The next string, or null when input is exhausted.
Throws:
  `IOException`

### close

public void close()

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `LineReader`

### toString

public String toString()

Overrides:
  `toString` in class `Object`