Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use StringTokenizer in combination with BufferedReader  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .

 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
bhanu chowdary
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of StringTokenizer you can use String split() method easily with BufferedReader if you dont have any newline characters in your file.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!