Reading from a file
Please support our Java advertiser: Programming Forums
![]() |
•
•
Posts: 97
Reputation:
Solved Threads: 0
Hello All,
I am trying to figure the best route to take for this problem. I am trying to read from a text file. The text file is setup at follows:
John 90 98 9009
Smith 90 87 87987
Eric 76 66 23443...
I am trying the figure how to read only the names from the files. I cannot use String tokenizer or split().
I have tried everything that I can think of. Right now I can read the entire line.
No code please, only suggestions and comments.
Thank you,
I am trying to figure the best route to take for this problem. I am trying to read from a text file. The text file is setup at follows:
John 90 98 9009
Smith 90 87 87987
Eric 76 66 23443...
I am trying the figure how to read only the names from the files. I cannot use String tokenizer or split().
I have tried everything that I can think of. Right now I can read the entire line.
No code please, only suggestions and comments.
Thank you,
Last edited by KimJack : Sep 8th, 2007 at 12:04 pm. Reason: forgot something
Once you read the line, look for position of empty space in your string from beginning and then substring it. String method charAt(num) and substring(int beginIndex, int endIndex) will help you.
Second option is to use Serialization because you know how the text is formated (meaning text followed by number separated by one empty space)
Second option is to use Serialization because you know how the text is formated (meaning text followed by number separated by one empty space)
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), The London Android Group
Yes, if you use second approach and simply ignore numerical content after empty character
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
Other Threads in the Java Forum
- problems with reading random access line from a file (C++)
- problems with reading in file (C++)
- First year assigment on reading file, sorting and outputting invoice (C++)
- Error Message Concerning Reading File From A Drive (C++)
- loop to create arrays when reading a file (Java)
- URGENT - Reading from txt file into a 2 dimension array (Java)
- reading a file into code (Java)
- reading and printing a file to screen in C (C)
Other Threads in the Java Forum
- Previous Thread: Jdbc...
- Next Thread: I can't display the right output (else if statement)
•
•
•
•
Views: 805 | Replies: 3 | Currently Viewing: 1 (0 members and 1 guests)






Linear Mode