Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing data into the same file.  RSS feed

 
Aji Prasetyo
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to write data (int) into a files, but I don't want to erase the file's contents. I mean, I want to fill the data I get into a file. How do I do that?
So far in my code, the current data always overwrite the last data.

Thanks in advance.
 
Pablo Saavedra
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a boolean parameter in the FileOutputStream class's constructor, which tells the output stream whether it should write the bytes at the beginning or at the end of the file. Set it to true in order to append the data to the existing data.

Regards.
 
Aji Prasetyo
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Pablo,

I got it. Thank you for your advice.

Regards.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!