+2003-03-20 Michael Koch <konqueror@gmx.de>
+
+ * java/io/FileInputStream.java
+ (getChannel): New implementation.
+ * java/io/FileOutputStream.java
+ (ch): New member variable.
+ (getChannel): Implemented.
+ * java/io/RandomAccessFile.java
+ (RandomAccessFile): Throws FileNotFoundException instead of
+ IOException.
+ (getChannel): New method.
+ (ch): New member variable.
+
2003-03-20 Michael Koch <konqueror@gmx.de>
* java/io/DataOutputStream.java,
package java.io;
import java.nio.channels.FileChannel;
+import gnu.java.nio.FileChannelImpl;
/**
* @author Warren Levy <warrenl@cygnus.com>
public FileChannel getChannel ()
{
- return ch;
+ synchronized (this)
+ {
+ if (ch == null)
+ ch = new FileChannelImpl (fd, false, this);
+
+ return ch;
+ }
}
}
package java.io;
import java.nio.channels.FileChannel;
+import gnu.java.nio.FileChannelImpl;
/**
* @author Tom Tromey <tromey@cygnus.com>
fd.close();
}
- // Instance variables.
- private FileDescriptor fd;
-
public FileChannel getChannel ()
{
- return null;
+ synchronized (this)
+ {
+ if (ch == null)
+ ch = new FileChannelImpl (fd, true, this);
+
+ return ch;
+ }
}
+
+ // Instance variables.
+ private FileDescriptor fd;
+ private FileChannel ch;
}
package java.io;
+import java.nio.channels.FileChannel;
+import gnu.java.nio.FileChannelImpl;
+
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date September 25, 1998
return fd.length();
}
- public RandomAccessFile (String fileName, String mode) throws IOException
+ public RandomAccessFile (String fileName, String mode)
+ throws FileNotFoundException
{
int fdmode;
if (mode.compareTo ("r") == 0)
in = new DataInputStream (new FileInputStream (fd));
}
- public RandomAccessFile (File file, String mode) throws IOException
+ public RandomAccessFile (File file, String mode) throws FileNotFoundException
{
this (file.getPath(), mode);
}
out.writeUTF(s);
}
+ public FileChannel getChannel ()
+ {
+ synchronized (this)
+ {
+ if (ch == null)
+ ch = new FileChannelImpl (fd, true, this);
+
+ return ch;
+ }
+ }
// The underlying file.
private FileDescriptor fd;
// The corresponding input and output streams.
private DataOutputStream out;
private DataInputStream in;
+ private FileChannel ch;
}