| | |
Reading from a file
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2006
Posts: 114
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 1: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, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development 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, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- 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)
| Thread Tools | Search this Thread |
2dgraphics android api apple applet application arguments array arrays automation banking binary binarytree bluetooth capture chat chatprogramusingobjects class classes client code color component count database derby design eclipse eclipsedevelopment encryption error event exception fractal game givemetehcodez graphics gridlayout gui html ide if_statement image input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list loop macintosh map method methods midlethttpconnection mobile netbeans newbie object os print printing problem producer program programming project projectideas read recursion reference replaysolutions ria scanner screen server set size sms sort sourcelabs sql stop string swing threads transforms tree ui unicode validation windows






