Class FlatFileEx2
- All Implemented Interfaces:
AutoCloseable,ResultSet,Wrapper
Reads in a data set in a space separated form.
This example reads a set of stock prices in a space separated form.
The first few lines of the data set are as follows:
Date Open High Low Close Volume
28-Apr-03 3.3 3.34 3.27 3.33 37224400
25-Apr-03 3.35 3.38 3.25 3.26 57117400
24-Apr-03 3.32 3.40 3.30 3.38 47019800
23-Apr-03 3.34 3.44 3.30 3.37 63243800
22-Apr-03 3.24 3.38 3.22 3.36 67392500
The first line contains the column names, with a comma as the separator. The
rest of the lines contain data, one day per line. The first column is
Date data and the last column is int data. All of
the rest is double data. A data type class is set for each
column. The parser is explicitly set for the date column, because it cannot
be guessed by FlatFile. The date's locale is set to
US, so that the example will work with a different default
locale.
A Tokenizer is created and used that counts multiple separators
(spaces) as one separator.
This example extends the class FlatFile. The FlatFileEx2
constructor reads the line containing the column names, parses the names, and
sets the column names.
The class FlatFileEx2 is used in the method main.
The data set is assumed to be in a file called "SUNW.txt" in the same
location as the example class file, so that the
getResourceAsStream method can be used to open the file as a
stream. Some of the columns are printed out for each stock price.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.imsl.io.FlatFile
FlatFile.ParserNested classes/interfaces inherited from class com.imsl.io.AbstractFlatFile
AbstractFlatFile.FlatFileSQLException, AbstractFlatFile.FlatFileSQLFeatureNotSupportedException -
Field Summary
Fields inherited from class com.imsl.io.FlatFile
PARSE_BYTE, PARSE_DOUBLE, PARSE_FLOAT, PARSE_INTEGER, PARSE_LONG, PARSE_SHORTFields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.imsl.io.FlatFile
doGetBytes, doNext, getColumnCount, getHoldability, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getRowId, getRowId, getSQLXML, getSQLXML, isClosed, isWrapperFor, readLine, setColumnClass, setColumnParser, setDateColumnParser, unwrap, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateRowId, updateRowId, updateSQLXML, updateSQLXMLMethods inherited from class com.imsl.io.AbstractFlatFile
absolute, afterLast, beforeFirst, beginGet, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, findColumnName, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getColumnClass, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getInt, getInt, getLong, getLong, getMetaData, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getShort, getShort, getStatement, getString, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setColumnName, setFetchDirection, setFetchSize, setWarning, updateArray, updateArray, updateBigDecimal, updateBigDecimal, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateShort, updateShort, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, wasNullMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.sql.ResultSet
updateObject, updateObject, updateObject, updateObject
-
Constructor Details
-
FlatFileEx2
- Throws:
IOException
-
-
Method Details
-
main
- Throws:
SQLExceptionIOException
-