• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

making sure file is fully closed on operating system

 
Travis Williams
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my J2EE app, I'm updating a text file and then immediately sending it as an email attachment via JavaMail.
My only concern is that, when testing it, if I write to the text file and then immediately open it in Wordpad, sometimes the old version of the text file loads, not the new version. However, if I close the file and reopen the new information is now there.
Is there a way for me to ensure that the file is fully closed on the operating system before I actually send the email? If I could just send text, this wouldn't be a problem but I must send it as an attachment.
This is an idea of the code I'm using:
FileWriter fw = new FileWriter(subscribers);
BufferedWriter out = new BufferedWriter(fw);
//write to the file
out.close();
fw.close();
//send the file as an attachment using JavaMail
Thanks for any help,
Travis
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic