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.

From-SVN: r64609
This commit is contained in:
Michael Koch 2003-03-20 07:54:24 +00:00 committed by Michael Koch
parent 04b3370bfd
commit 10b33028a2
4 changed files with 50 additions and 7 deletions

View file

@ -38,6 +38,9 @@ exception statement from your version. */
package java.io;
import java.nio.channels.FileChannel;
import gnu.java.nio.FileChannelImpl;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date September 25, 1998
@ -78,7 +81,8 @@ public class RandomAccessFile implements DataOutput, DataInput
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)
@ -101,7 +105,7 @@ public class RandomAccessFile implements DataOutput, DataInput
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);
}
@ -276,10 +280,21 @@ public class RandomAccessFile implements DataOutput, DataInput
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;
}