+2004-04-20 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/io/FileDescriptor.java: (FileDescriptor) Added public
+ constructor. (valid) Added null check.
+
+2004-04-20 Guilhem Lavaux <guilhem@kaffe.org>
+
+ Reported by Nektarios Papadopoulos <npapadop@inaccessnetworks.com>
+ * java/io/FileOutputStream.java
+ (FileOutputStream) Reorganized constructors. Constructors now
+ check whether the given path is directory.
+
2004-04-20 Michael Koch <konqueror@gmx.de>
* java/net/Authenticator.java,
/**
* This method is used to initialize an invalid FileDescriptor object.
*/
+ public FileDescriptor()
+ {
+ channel = null;
+ }
+
+ /**
+ * This method is used to initialize a FileDescriptor object.
+ */
FileDescriptor(ByteChannel channel)
{
this.channel = channel;
*/
public boolean valid ()
{
- return channel.isOpen();
+ return channel != null && channel.isOpen();
}
}
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);
}
/**
public FileOutputStream (File file)
throws SecurityException, FileNotFoundException
{
- this (file.getPath(), false);
+ this (file, false);
}
/**
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));
}
/**