Forums Register Login

Populating a JTable from a text file

+Pie Number of slices to send: Send
I am trying to populate a JTable with data from a text file. In the text file, the fields are separated by tabs (but could be separated by commas, spaces, etc). How is this done.
Thanks for your help, I am a Java rookie!!!
+Pie Number of slices to send: Send
Hi Stacy,

what u can do is like this.
1) read a line from the file using BufferedReader
2) Tokenize this line using StringTokenizer by default StringTokenizer will separate tokens on the basis of tab and space character.
3)Now you consider each token one by one and check if it contains
a , ( comma ) . in case it contains comma then you further tokenize this token using , as delimiter and so on. untill you reach the actual field.
4) keep on adding the final token to a Vector
5) and pass this Vector to JTable Constructor.
regards
Deekasha

To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2002 times.
Similar Threads
Populating JTable from a textfile
JTable
JTable "..."
JTable
JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:49:20.