title: Is there a way to save a file I'm writing to in Java without using the .close() method?
body: <p>I'm getting an input of ID numbers and writing each ID into the file as it is entered. The ID's written into the file are just a backup in case the program crashes for some reason (it's a small personal thing). So, if there's an unexpected shutdown, I'll just have a text file containing all of the ID numbers I've already entered. However, I'm noticing that the ID's don't get saved into the file until the .close() is executed when I manually close it, but that would just defeat the purpose.</p>
  
  <p>This is my first time doing anything like this, so I'm not sure what the proper approach is. Is there some way to save the text without closing the BufferedWriter? Or is it acceptable to close it and open it right back up somehow?</p>
  
  <p>Thank you for your suggestions!</p>