| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Thanks so much for the help.
You'll want to fw.close() or fw.flush() the file. Otherwise the
output will be buffered until the object is finalized (most output
stream objects close themselves on finalization -- since you
obviously forgot). But since your application probably just
terminates immediately, it's most likely that none of your objects
are ever finalized, and thus your file is never closed.
That did the trick - I am sure the other sample sent in would work as
well. Now my question is which way is better of the following two
methodologies: (most code snipped for brevity)
1) ** USING BUFFERED WRITER - EXAMPLE FROM JAVA.SUN.COM FOR Java 1.2 **
File fileOut = new File("/space/users/swd/java/testFile.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(fileOut));
out.write("we are writting to a file ");
out.close();
2) ** USE FILEWRITER AS I ORIGINALLY POSTED WITH HELP FROM ABOVE **
File fileOut = new File("/space/users/swd/java/testFile.txt");
FileWriter fw = new FileWriter(fileOut);
fw.write("docHeader\n");
fw.close();
IOW should I use the BufferedWriter wrapper or not?
| References: | |
| >Re: Writing to a file (From: Jon Lucenius <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.