Package com.google.code.externalsorting
Class BinaryFileBuffer
java.lang.Object
com.google.code.externalsorting.BinaryFileBuffer
- All Implemented Interfaces:
IOStringStack
This is essentially a thin wrapper on top of a BufferedReader... which keeps
the last line in memory.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a BinaryFileBuffer wrapping the given BufferedReader. -
Method Summary
-
Constructor Details
-
BinaryFileBuffer
Constructs a BinaryFileBuffer wrapping the given BufferedReader.- Parameters:
r- the BufferedReader to wrap- Throws:
IOException- if an I/O error occurs
-
-
Method Details
-
close
Closes the underlying BufferedReader.- Specified by:
closein interfaceIOStringStack- Throws:
IOException- if an I/O error occurs
-
empty
public boolean empty()Checks if the buffer is empty.- Specified by:
emptyin interfaceIOStringStack- Returns:
- true if there are no more lines to read
-
peek
Returns the next line in the buffer without removing it.- Specified by:
peekin interfaceIOStringStack- Returns:
- the next line as a String, or null if empty
-
pop
Removes and returns the next line in the buffer.- Specified by:
popin interfaceIOStringStack- Returns:
- the next line as a String
- Throws:
IOException- if an I/O error occurs
-