jQuery in Action, 2nd edition*
The moose likes I/O and Streams and the fly likes making sure file is fully closed on operating system Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "making sure file is fully closed on operating system" Watch "making sure file is fully closed on operating system" New topic
Author

making sure file is fully closed on operating system

Travis Williams
Greenhorn

Joined: Jan 28, 2002
Posts: 10
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: making sure file is fully closed on operating system