• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing to a file

 
Jojo Wilson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is an example of a way to create a file and write some text to it?
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The moderators don't usually approve of just supplying code, but this is an instance where it's just easer if i give you this... This will right a string "s" to a file with the name (again a string) "filename". if no such file exists, it will create one.

the following static method will then read the filename String f and return the contents as a String, which you can partition into the information you need.

Don't tell anyone i gave you a hand-out
 
Jojo Wilson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it using ObjectOutputStream instead of PrintWriter. I appreciate your help.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic