Help-Read line from the text file

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2007
Posts: 27
Reputation: rainny has a little shameless behaviour in the past 
Solved Threads: 1
rainny rainny is offline Offline
Light Poster

Help-Read line from the text file

 
0
  #1
Feb 27th, 2009
Hi, does anyone know how to read the specified line from a text file? And by create a program, we can load what is write inside the text file and read line by line to show at the program.

Does anyone have idea on it?

Thanks and regards
Rainny
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Help-Read line from the text file

 
0
  #2
Feb 27th, 2009
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 18
Reputation: Taniotoshi is an unknown quantity at this point 
Solved Threads: 0
Taniotoshi's Avatar
Taniotoshi Taniotoshi is offline Offline
Newbie Poster

Re: Help-Read line from the text file

 
0
  #3
Feb 28th, 2009
Not really clear.
And by create a program, we can load what is write inside the text file and read line by line to show at the program.
Do I understand well?
You want a program able to output contents of a file. That's it?

If yes...
Another solution could be the use of a Scanner ,with your file as a parameter.
http://java.sun.com/j2se/1.5.0/docs/...l/Scanner.html
You should focus on hasnextLine() and nextLine() methods.

You could then easily print this directly... But is your program just about this? Will not you need to re-use these contents for other purposes? If so, you should store them somewhere... An easy solution would be the use of an ArrayList...
http://java.sun.com/j2se/1.4.2/docs/...ArrayList.html
You should focus on the constructor, add and get methods...

So:
- read file using Scanner
- Store contents in ArrayList
- print ArrayList

If no...
Please re-formulate...

cheers
and some people still think our thoughts do not reach computers...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1187 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC