Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a TableModel to access a file directly

Status
Not open for further replies.
May 13, 2002
75
GB
Hi,

I'm writing an application that opens up a specific type of data file into a JTable. If the file is small then copied the data into Vector then created a class that extends AbstractTableModel to access the data from the Vector. Most of the data is Strings but some is of a new type Chem that has it's own renderer which is why i've done it this way. This is fine for small to medium files, but for very big files then memory is a problem. To my question...

Is it possible to create some code in the
Code:
public Object getValueAt(int row, int column)
section of your TableModel class to access a position in a file directly ?

Obviously this would slow the table down a fair amount as the user scrolls down but it would mean that a user could have access to a very large data file all at once. I had a look at the InputStream class, there is a Mark method but it only creates one mark rather then allowing me to mark every 'record'. Maybe i could use the CharArrayReader if i somehow parsed the file and stored the locations of all the records then used
Code:
read(char[] b, int off, int len)
??


Any ideas ? Alistair [monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top