From e54f2ea822f074dc11ba851d25f566d92163ba26 Mon Sep 17 00:00:00 2001 From: mkoch Date: Wed, 19 Mar 2003 12:13:41 +0000 Subject: [PATCH] 2003-03-19 Michael Koch * java/io/FileOutputStream.java (FileOutputStream): New constructor, merged from classpath. * java/io/FileWriter.java (FileWriter): New constructor, merged from classpath. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64574 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 7 +++++++ libjava/java/io/FileOutputStream.java | 26 ++++++++++++++++++++++++++ libjava/java/io/FileWriter.java | 21 ++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index ab1c75b..5d2d047 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2003-03-19 Michael Koch + + * java/io/FileOutputStream.java + (FileOutputStream): New constructor, merged from classpath. + * java/io/FileWriter.java + (FileWriter): New constructor, merged from classpath. + 2003-03-18 Michael Koch * java/awt/ScrollPane.java diff --git a/libjava/java/io/FileOutputStream.java b/libjava/java/io/FileOutputStream.java index 5ea24e5..eee3449 100644 --- a/libjava/java/io/FileOutputStream.java +++ b/libjava/java/io/FileOutputStream.java @@ -47,6 +47,32 @@ public class FileOutputStream extends OutputStream this (file.getPath(), false); } + /** + * This method initializes a FileOutputStream object to write + * to the specified File object. The file is created if it + * does not exist, and the bytes written are written starting at the + * beginning of the file if the append parameter is + * false. Otherwise bytes are written at the end of the + * file. + *

+ * Before opening a file, a security check is performed by calling the + * checkWrite method of the SecurityManager (if + * one exists) with the name of the file to be opened. An exception is + * thrown if writing is not allowed. + * + * @param file The File object this stream should write to + * @param append true to append bytes to the end of the file, + * or false to write bytes to the beginning + * + * @exception SecurityException If write access to the file is not allowed + * @exception FileNotFoundException If a non-security error occurs + */ + public + FileOutputStream(File file, boolean append) throws FileNotFoundException + { + this(file.getPath(), append); + } + public FileOutputStream (FileDescriptor fdObj) throws SecurityException { diff --git a/libjava/java/io/FileWriter.java b/libjava/java/io/FileWriter.java index 5217f9e..b7f8579 100644 --- a/libjava/java/io/FileWriter.java +++ b/libjava/java/io/FileWriter.java @@ -1,5 +1,5 @@ /* FileWriter.java -- Convenience class for writing to files. - Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -79,6 +79,25 @@ public class FileWriter extends OutputStreamWriter /** * This method initializes a new FileWriter object to write + * to the specified File object. + * + * @param file The File object to write to. + * @param append true to start adding data at the end of the + * file, false otherwise. + * + * @param SecurityException If writing to this file is forbidden by the + * SecurityManager. + * @param IOException If any other error occurs + */ + public FileWriter(File file, boolean append) throws IOException + { + super(new FileOutputStream(file, append)); + } + + /*************************************************************************/ + + /** + * This method initializes a new FileWriter object to write * to the specified FileDescriptor object. * * @param fd The FileDescriptor object to write to -- 2.7.4