| | |
Reading from a file
![]() |
•
•
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 |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






