src/share/classes/java/io/FileWriter.java

Print this page
rev 10048 : 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
Reviewed-by:


  29 /**
  30  * Convenience class for writing character files.  The constructors of this
  31  * class assume that the default character encoding and the default byte-buffer
  32  * size are acceptable.  To specify these values yourself, construct an
  33  * OutputStreamWriter on a FileOutputStream.
  34  *
  35  * <p>Whether or not a file is available or may be created depends upon the
  36  * underlying platform.  Some platforms, in particular, allow a file to be
  37  * opened for writing by only one <tt>FileWriter</tt> (or other file-writing
  38  * object) at a time.  In such situations the constructors in this class
  39  * will fail if the file involved is already open.
  40  *
  41  * <p><code>FileWriter</code> is meant for writing streams of characters.
  42  * For writing streams of raw bytes, consider using a
  43  * <code>FileOutputStream</code>.
  44  *
  45  * @see OutputStreamWriter
  46  * @see FileOutputStream
  47  *
  48  * @author      Mark Reinhold
  49  * @since       JDK1.1
  50  */
  51 
  52 public class FileWriter extends OutputStreamWriter {
  53 
  54     /**
  55      * Constructs a FileWriter object given a file name.
  56      *
  57      * @param fileName  String The system-dependent filename.
  58      * @throws IOException  if the named file exists but is a directory rather
  59      *                  than a regular file, does not exist but cannot be
  60      *                  created, or cannot be opened for any other reason
  61      */
  62     public FileWriter(String fileName) throws IOException {
  63         super(new FileOutputStream(fileName));
  64     }
  65 
  66     /**
  67      * Constructs a FileWriter object given a file name with a boolean
  68      * indicating whether or not to append the data written.
  69      *




  29 /**
  30  * Convenience class for writing character files.  The constructors of this
  31  * class assume that the default character encoding and the default byte-buffer
  32  * size are acceptable.  To specify these values yourself, construct an
  33  * OutputStreamWriter on a FileOutputStream.
  34  *
  35  * <p>Whether or not a file is available or may be created depends upon the
  36  * underlying platform.  Some platforms, in particular, allow a file to be
  37  * opened for writing by only one <tt>FileWriter</tt> (or other file-writing
  38  * object) at a time.  In such situations the constructors in this class
  39  * will fail if the file involved is already open.
  40  *
  41  * <p><code>FileWriter</code> is meant for writing streams of characters.
  42  * For writing streams of raw bytes, consider using a
  43  * <code>FileOutputStream</code>.
  44  *
  45  * @see OutputStreamWriter
  46  * @see FileOutputStream
  47  *
  48  * @author      Mark Reinhold
  49  * @since       1.1
  50  */
  51 
  52 public class FileWriter extends OutputStreamWriter {
  53 
  54     /**
  55      * Constructs a FileWriter object given a file name.
  56      *
  57      * @param fileName  String The system-dependent filename.
  58      * @throws IOException  if the named file exists but is a directory rather
  59      *                  than a regular file, does not exist but cannot be
  60      *                  created, or cannot be opened for any other reason
  61      */
  62     public FileWriter(String fileName) throws IOException {
  63         super(new FileOutputStream(fileName));
  64     }
  65 
  66     /**
  67      * Constructs a FileWriter object given a file name with a boolean
  68      * indicating whether or not to append the data written.
  69      *