0N/A/*
2362N/A * Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.io;
0N/A
0N/A
0N/A/**
0N/A * Convenience class for writing character files. The constructors of this
0N/A * class assume that the default character encoding and the default byte-buffer
0N/A * size are acceptable. To specify these values yourself, construct an
0N/A * OutputStreamWriter on a FileOutputStream.
0N/A *
0N/A * <p>Whether or not a file is available or may be created depends upon the
0N/A * underlying platform. Some platforms, in particular, allow a file to be
0N/A * opened for writing by only one <tt>FileWriter</tt> (or other file-writing
0N/A * object) at a time. In such situations the constructors in this class
0N/A * will fail if the file involved is already open.
0N/A *
0N/A * <p><code>FileWriter</code> is meant for writing streams of characters.
0N/A * For writing streams of raw bytes, consider using a
0N/A * <code>FileOutputStream</code>.
0N/A *
0N/A * @see OutputStreamWriter
0N/A * @see FileOutputStream
0N/A *
0N/A * @author Mark Reinhold
0N/A * @since JDK1.1
0N/A */
0N/A
0N/Apublic class FileWriter extends OutputStreamWriter {
0N/A
0N/A /**
0N/A * Constructs a FileWriter object given a file name.
0N/A *
0N/A * @param fileName String The system-dependent filename.
0N/A * @throws IOException if the named file exists but is a directory rather
0N/A * than a regular file, does not exist but cannot be
0N/A * created, or cannot be opened for any other reason
0N/A */
0N/A public FileWriter(String fileName) throws IOException {
0N/A super(new FileOutputStream(fileName));
0N/A }
0N/A
0N/A /**
0N/A * Constructs a FileWriter object given a file name with a boolean
0N/A * indicating whether or not to append the data written.
0N/A *
0N/A * @param fileName String The system-dependent filename.
0N/A * @param append boolean if <code>true</code>, then data will be written
0N/A * to the end of the file rather than the beginning.
0N/A * @throws IOException if the named file exists but is a directory rather
0N/A * than a regular file, does not exist but cannot be
0N/A * created, or cannot be opened for any other reason
0N/A */
0N/A public FileWriter(String fileName, boolean append) throws IOException {
0N/A super(new FileOutputStream(fileName, append));
0N/A }
0N/A
0N/A /**
0N/A * Constructs a FileWriter object given a File object.
0N/A *
0N/A * @param file a File object to write to.
0N/A * @throws IOException if the file exists but is a directory rather than
0N/A * a regular file, does not exist but cannot be created,
0N/A * or cannot be opened for any other reason
0N/A */
0N/A public FileWriter(File file) throws IOException {
0N/A super(new FileOutputStream(file));
0N/A }
0N/A
0N/A /**
0N/A * Constructs a FileWriter object given a File object. If the second
0N/A * argument is <code>true</code>, then bytes will be written to the end
0N/A * of the file rather than the beginning.
0N/A *
0N/A * @param file a File object to write to
0N/A * @param append if <code>true</code>, then bytes will be written
0N/A * to the end of the file rather than the beginning
0N/A * @throws IOException if the file exists but is a directory rather than
0N/A * a regular file, does not exist but cannot be created,
0N/A * or cannot be opened for any other reason
0N/A * @since 1.4
0N/A */
0N/A public FileWriter(File file, boolean append) throws IOException {
0N/A super(new FileOutputStream(file, append));
0N/A }
0N/A
0N/A /**
0N/A * Constructs a FileWriter object associated with a file descriptor.
0N/A *
0N/A * @param fd FileDescriptor object to write to.
0N/A */
0N/A public FileWriter(FileDescriptor fd) {
0N/A super(new FileOutputStream(fd));
0N/A }
0N/A
0N/A}