| Author |
How to read data from a file...
|
Jonathan King
Greenhorn
Joined: Jan 28, 2004
Posts: 14
|
|
I am at a lost as to where to begin... I need to read data from a file (Example: 2c 4h 5d 9s) then according to what letter is next to the number, I place in the proper array spot. (So I am guessing multi-dimensional array?) Umm... data is 13 'couplets' and I am at a total loss of where to begin. Do I need to use a string tokenizer, get one couplet, and then how do I tell from the couplet what letter it is.... I keep thinking this has to be simple, and I am just thinking too complex. I'm just not sure how to read mixed data types from a file (int/char pairs), and then how to figure out specifically what letter is from each pair. ANYWAY... ANY help at all on this problem would be MOST appreciated!!! Jon
|
 |
Timmy Marks
Ranch Hand
Joined: Dec 01, 2003
Posts: 226
|
|
You could try the following: create a BufferedReader that is connected to a FileReader that is created using your file. using readLine() you can read the lines of the file one at a time into a String then tokenize the String you just read into smaller strings. Then you could use the charAt() method of the String class to get each character. Hope this helps
|
 |
Jonathan King
Greenhorn
Joined: Jan 28, 2004
Posts: 14
|
|
Okay, thanks for the tip! Does this look like proper code for a situation for this? or is this not legal usage of charAt? Can I parse it like that? Any answers will be appreciated!! Jon
|
 |
 |
|
|
subject: How to read data from a file...
|
|
|