[Logo]
Forums Register Login
How to read data from a file...
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
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
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
What's wrong? Where are you going? Stop! Read this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature


This thread has been viewed 829 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 26, 2018 19:15:37.