| | |
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 |
Tag cloud for Java
addressbook android api apple applet application arguments array arrays automation binary bluetooth button calculator chat class classes client code columns component converter database draw eclipse error errors event exception file fractal ftp game givemetehcodez graphics gridlayout gui helpwithhomework html ide image inetaddress input integer j2me japplet java javaprojects jme jmf jni jpanel julia link linux list loop map method methods midlethttpconnection mobile netbeans newbie number objects openjavafx oracle php print problem program programming project projects recursion rim scanner screen server set signing size smart sms socket sort sql storm string support swing test threads time tree unlimited variablebinding webservices windows






