[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: java.io.FileOutputStream
From: |
Guilhem Lavaux |
Subject: |
FYI: java.io.FileOutputStream |
Date: |
Fri, 16 Apr 2004 16:27:38 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 |
Hi,
We have been reported by Nektarios Papadopoulos
<address@hidden> a misbehaviour in
java.io.FileOutputStream. It should also check whether the given is
directory.
I've slightly reorganized the constructor to fix that.
ChangeLog entry:
2004-04-16 Guilhem Lavaux <address@hidden>
* java/io/FileOutputStream.java
(FileOutputStream) Reorganized constructors. Constructors now
check whether the given path is directory.
Index: java/io/FileOutputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/FileOutputStream.java,v
retrieving revision 1.29
diff -u -r1.29 FileOutputStream.java
--- java/io/FileOutputStream.java 8 Apr 2004 20:04:12 -0000 1.29
+++ java/io/FileOutputStream.java 16 Apr 2004 14:27:02 -0000
@@ -81,13 +81,7 @@
public FileOutputStream (String path, boolean append)
throws SecurityException, FileNotFoundException
{
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkWrite(path);
- ch = new FileChannelImpl (path, (append
- ? FileChannelImpl.WRITE
- | FileChannelImpl.APPEND
- : FileChannelImpl.WRITE));
+ this (new File(path), append);
}
/**
@@ -130,7 +124,7 @@
public FileOutputStream (File file)
throws SecurityException, FileNotFoundException
{
- this (file.getPath(), false);
+ this (file, false);
}
/**
@@ -156,7 +150,17 @@
public FileOutputStream (File file, boolean append)
throws FileNotFoundException
{
- this (file.getPath(), append);
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkWrite(path);
+
+ if (file.isDirectory())
+ throw new FileNotFoundException(file.getPath() + " is a directory");
+
+ ch = new FileChannelImpl (file.getPath(), (append
+ ? FileChannelImpl.WRITE
+ | FileChannelImpl.APPEND
+ : FileChannelImpl.WRITE));
}
/**
pgpPYj79LIiom.pgp
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: java.io.FileOutputStream,
Guilhem Lavaux <=