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 Java in General and the fly likes How to use StringTokenizer in combination with BufferedReader 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 » Java in General
Bookmark "How to use StringTokenizer in combination with BufferedReader " Watch "How to use StringTokenizer in combination with BufferedReader " New topic
Author

How to use StringTokenizer in combination with BufferedReader

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi

I am reading a File using a BufferedReader , the file consists of different Transactions, where each Transaction is seperated using a
Y2 word .

Please let me know how can i use BufferedReader in combination with
StringTokenizer ??

Please share your ideas .
Thanks in advance .


Save India From Corruption - Anna Hazare.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Don't use StringTokenizer, it's quite old. String.split can do almost exactly the same but is better.

There are two separate issues here:
1) read a file line by line. Check out BufferedReader, it has a nice method for that.

2) splitting each line. That's where String.split comes in.

I'm sure that if you get these both working separately you can combine them. Hint: the splitting goes into the reading loop


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
Instead of StringTokenizer you can use String split() method easily with BufferedReader if you dont have any newline characters in your file.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to use StringTokenizer in combination with BufferedReader
 
Similar Threads
I/O
Re: FileWriter write operation
Flat File Search
reading passwords and connections from a flat file
Problem !!