summaryrefslogtreecommitdiff
path: root/java/io/FileOutputStream.java
diff options
context:
space:
mode:
authorGuilhem Lavaux <guilhem@kaffe.org>2004-04-16 14:36:30 +0000
committerGuilhem Lavaux <guilhem@kaffe.org>2004-04-16 14:36:30 +0000
commit291b3270ca3ae32d576fad3c35d3a0b24fe18bef (patch)
tree2a792f07137825981f1a49ea5b50c5746666d3bb /java/io/FileOutputStream.java
parentaa717981c39aa077fa47f44299069516ecaaf58a (diff)
downloadclasspath-291b3270ca3ae32d576fad3c35d3a0b24fe18bef.tar.gz
Reported by Nektarios Papadopoulos <npapadop@inaccessnetworks.com>
* java/io/FileOutputStream.java (FileOutputStream) Reorganized constructors. Constructors now check whether the given path is directory.
Diffstat (limited to 'java/io/FileOutputStream.java')
-rw-r--r--java/io/FileOutputStream.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/java/io/FileOutputStream.java b/java/io/FileOutputStream.java
index a8c4b765e..8942871e4 100644
--- a/java/io/FileOutputStream.java
+++ b/java/io/FileOutputStream.java
@@ -81,13 +81,7 @@ public class FileOutputStream extends OutputStream
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 class FileOutputStream extends OutputStream
public FileOutputStream (File file)
throws SecurityException, FileNotFoundException
{
- this (file.getPath(), false);
+ this (file, false);
}
/**
@@ -156,7 +150,17 @@ public class FileOutputStream extends OutputStream
public FileOutputStream (File file, boolean append)
throws FileNotFoundException
{
- this (file.getPath(), append);
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkWrite(file.getPath());
+
+ if (file.isDirectory())
+ throw new FileNotFoundException(file.getPath() + " is a directory");
+
+ ch = new FileChannelImpl (file.getPath(), (append
+ ? FileChannelImpl.WRITE
+ | FileChannelImpl.APPEND
+ : FileChannelImpl.WRITE));
}
/**