Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing to a file



The textbooks would all seem to suggest that using a BufferedWriter to wrap
a FileWriter is a perfectly good thing to do.

If I remember correctly I think they even have a nice name for it. It is
called "decorating".

HTH

Harry Mantheakis
London, UK

> 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?




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.