# Class FastqReader

java.lang.Object
htsjdk.samtools.fastq.FastqReader

All Implemented Interfaces:
  `Closeable, AutoCloseable, Iterable<FastqRecord>, Iterator<FastqRecord>`

public class FastqReader extends Object implements Iterator<FastqRecord>, Iterable<FastqRecord>, Closeable
Reads a FASTQ file with four lines per record. WARNING: Despite the fact that this class implements Iterable, calling iterator() method does not start iteration from the beginning of the file. Developers should probably not call iterator() directly. It is provided so that this class can be used in Java for-each loop.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected static enum`
`FastqReader.LineType`
Enum of the types of lines we see in Fastq.

## Constructor Summary

Constructors
Constructor
Description
`FastqReader(BufferedReader reader)`
`FastqReader(File file)`
`FastqReader(File file, boolean skipBlankLines)`
Constructor
`FastqReader(File file, BufferedReader reader)`
`FastqReader(File file, BufferedReader reader, boolean skipBlankLines)`
Constructor

## Method Summary

Modifier and Type
Method
Description
`protected void`
`checkLine(String line, FastqReader.LineType kind)`
Checks that the line is neither null (representing EOF) or empty (blank line in file).
`void`
`close()`
`protected String`
`error(String msg)`
Generates an error message with line number information.
`File`
`getFile()`
`int`
`getLineNumber()`
`boolean`
`hasNext()`
`Iterator<FastqRecord>`
`iterator()`
WARNING: Despite the fact that this class implements Iterable, calling iterator() method does not start iteration from the beginning of the file.
`FastqRecord`
`next()`
`void`
`remove()`
`String`
`toString()`

### Methods inherited from class Object

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

### Methods inherited from interface Iterable

`forEach, spliterator`

### Methods inherited from interface Iterator

`forEachRemaining`

## Constructor Details

### FastqReader

public FastqReader(File file)

### FastqReader

public FastqReader(File file, boolean skipBlankLines)
Constructor

Parameters:
  `file` - of FASTQ to read read. Will be opened with htsjdk.samtools.util.IOUtil.openFileForBufferedReading
  `skipBlankLines` - should we skip blank lines ?

### FastqReader

public FastqReader(BufferedReader reader)

### FastqReader

public FastqReader(File file, BufferedReader reader, boolean skipBlankLines)
Constructor

Parameters:
  `file` - Name of FASTQ being read, or null if not known.
  `reader` - input reader . Will be closed by the close method
  `skipBlankLines` - should we skip blank lines ?

### FastqReader

public FastqReader(File file, BufferedReader reader)

## Method Details

### hasNext

public boolean hasNext()

Specified by:
  `hasNext` in interface `Iterator<FastqRecord>`

### next

public FastqRecord next()

Specified by:
  `next` in interface `Iterator<FastqRecord>`

### remove

public void remove()

Specified by:
  `remove` in interface `Iterator<FastqRecord>`

### iterator

public Iterator<FastqRecord> iterator()
WARNING: Despite the fact that this class implements Iterable, calling iterator() method does not start iteration from the beginning of the file. Developers should probably not call iterator() directly. It is provided so that this class can be used in Java for-each loop.

Specified by:
  `iterator` in interface `Iterable<FastqRecord>`

### getLineNumber

public int getLineNumber()

### getFile

public File getFile()

Returns:
  Name of FASTQ being read, or null if not known.

### close

public void close()

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

### checkLine

protected void checkLine(String line, FastqReader.LineType kind)
Checks that the line is neither null (representing EOF) or empty (blank line in file).

### error

protected String error(String msg)
Generates an error message with line number information.

### toString

public String toString()

Overrides:
  `toString` in class `Object`