Top Description Fields Constructors Methods
com.google.common.io

public final Class LineReader

extends Object
Class Inheritance
Annotations
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, com.google.common.io.CharStreams.createBuffer

A class for reading lines of text. Provides the same functionality as java.io.BufferedReader#readLine() but for all Readable objects, not just instances of Reader.
Author
Chris Nokleberg
Since
1.0

Field Summary

Modifier and TypeField and Description
private final char[]
private final CharBuffer
private final LineBuffer
private final Queue<String>
private final Readable
private final Reader

Constructor Summary

AccessConstructor and Description
public
LineReader(Readable readable)

Creates a new instance that will read lines from the given Readable object.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

a String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached.
readLine
()

Reads a line of text.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufback to summary
private final char[] buf
cbufback to summary
private final CharBuffer cbuf
lineBufback to summary
private final LineBuffer lineBuf
linesback to summary
private final Queue<String> lines
readableback to summary
private final Readable readable
readerback to summary
private final Reader reader
Annotations
@CheckForNull

Constructor Detail

LineReaderback to summary
public LineReader(Readable readable)

Creates a new instance that will read lines from the given Readable object.

Method Detail

readLineback to summary
public String readLine() throws IOException

Reads 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 ("\r\n").

Returns:String

a String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached.

Annotations
@CanIgnoreReturnValue
@CheckForNull
Exceptions
IOException:
if an I/O error occurs