Top Description Fields Constructors Methods
org.hsqldb.cmdline.sqltool

public Class FileRecordReader

extends Object
Class Inheritance
Imports
java.net.URL, java.io.IOException, .UnsupportedEncodingException, .InputStreamReader, java.util.regex.Pattern, .Matcher

This class does not impement or extend java.io classes/interfaces, and is not a Reader in the sense of java.io.Reader. It is a 'reader' in the sense that it provides a method that reads and return records from a text file. The unique use case here is that records are delimited with a regular expression pattern yet the file contents are read incrementally to minimize RAM usage.

Field Summary

Modifier and TypeField and Description
private char[]
public static final int
private long
private InputStreamReader
private Pattern
private StringBuilder
private URL

Constructor Summary

AccessConstructor and Description
public
FileRecordReader(String filePath, String recordDelimiterRegex, String encoding)

Legacy constructor.

public
FileRecordReader(URL inUrl, String recordDelimiterRegex, String encoding)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Free up resources and close all potentially open I/O streams.

public String
public boolean
public static void
main(String[] sa)

To be replaced by proper unit test class

public String
nextRecord()

Returns: null if no more records in input file

private void
reload(boolean
If true, grab 2 x as many bytes as previous read.
increaseBuffer
)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

charBufferback to summary
private char[] charBuffer
INITIAL_CHARBUFFER_SIZEback to summary
public static final int INITIAL_CHARBUFFER_SIZE
postReadback to summary
private long postRead
readerback to summary
private InputStreamReader reader
recordPatternback to summary
private Pattern recordPattern
stringBufferback to summary
private StringBuilder stringBuffer
urlback to summary
private URL url

Constructor Detail

FileRecordReaderback to summary
public FileRecordReader(String filePath, String recordDelimiterRegex, String encoding) throws IOException, UnsupportedEncodingException

Legacy constructor. See following constructor for documentation.

FileRecordReaderback to summary
public FileRecordReader(URL inUrl, String recordDelimiterRegex, String encoding) throws IOException, UnsupportedEncodingException
Exceptions
UnsupportedEncodingException:
on error
PatternSyntaxException:
on error

Method Detail

closeback to summary
public void close() throws IOException

Free up resources and close all potentially open I/O streams.

getNameback to summary
public String getName()
isOpenback to summary
public boolean isOpen()
mainback to summary
public static void main(String[] sa) throws IOException

To be replaced by proper unit test class

Exceptions
IOException:
on error
nextRecordback to summary
public String nextRecord() throws IOException
Returns:String

null if no more records in input file

Exceptions
IOException:
on error
reloadback to summary
private void reload(boolean increaseBuffer) throws IOException
Parameters
increaseBuffer:boolean

If true, grab 2 x as many bytes as previous read.

Exceptions
IOException:
on error
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.