This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading and Writing Strings  RSS feed

 
Steve O Thomas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. I am new to Java (real new!) and am trying to write a small I/O program. Opening and closing files is not a problem, but what I am haveing trouble with is a) reading a line and then (possibly) manipulating this line using some of the tokenizer functions, and then writing this line to a different file. I am having trouble with how all of this streaming business works! Any ideas?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have to use streams or are you allowed to use Readers/Writers?
If so then you can use FileReader/Writer or (even better) BufferedReader/Writer. The advantage to the buffered one is that it allows you to read lines of text at a time, which you can the tokenize.
Be wary, from memory the readLine may skip blank lines, but I'd have to go check...
Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!