This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes reading lines from file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "reading lines from file" Watch "reading lines from file" New topic

reading lines from file

catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
Once i have loaded a file into my program how do i read the lines of codes and the blank lines? is there any method for that? Let say i want to get executable lines which has ; (semicolons) at the end, how do i do that?
Please help me!!!
[ May 15, 2006: Message edited by: catherine matthews ]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38075
Do you mean how do you compile a .java file into bytecode?
Or do you mean how do you parse a text file to see which line ends with a ";"?
Your original post is rather ambiguous.

If you are reading lines from a text file, you want some sort of class which reads the lines, either with a file reading class. I presume you are familiar with the part of the Java tutorial which deals with IO (= input and output)? You should find all you need to know about reading from text files there.

You tend to find these file reading and scanning classes are able to read each line from a text file as a String. There ought to be a method in the API telling you whether a String ends with something or not . . .

I hope I have ansered the question you meant to ask.

prasanna kanth

Joined: May 14, 2006
Posts: 28
It's a simple snippet, I hope it could help u

I hope this code will help fine,
for Future information on StringTokenizer :

catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
thanksya... i got it
It is sorta covered in the JavaRanch Style Guide.
subject: reading lines from file
Similar Threads
duplicate lines in a text file
unix / manipulating the content of a file
read blocks of lines from file
Reading file
read specific line from text file