This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Appending to a file  RSS feed

 
Adam Kjems
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I'm currently writing a java program that allows a user to input a name that is then saved to a .txt file. It works fine if I run the program once but when I run the program again it adds the data to the same line. Is there a way I can make the program add the names to a new line of text in the .txt file. My program has multiple classes, belows is only the one that actually writes to to the file. Thanks in advance

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API is a wonderful thing. Note that PrintWriter has a println() method that you can use instead of print() as you have.

I am also moving this to our I/O And Streams forum where these types of questions are discussed.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!