diff options
author | Michael Koch <konqueror@gmx.de> | 2003-03-23 11:54:42 +0000 |
---|---|---|
committer | Michael Koch <konqueror@gmx.de> | 2003-03-23 11:54:42 +0000 |
commit | 47b304ecc9511338537f83a9314ff418a2c80ed7 (patch) | |
tree | c6a8c26afc486f41568ac3160a476a2c5ba70774 /java/io/FileOutputStream.java | |
parent | 4dc800b5963b4a73e751c2ebe98b43b93b245216 (diff) | |
download | classpath-47b304ecc9511338537f83a9314ff418a2c80ed7.tar.gz |
2003-03-23 Michael Koch <konqueror@gmx.de>
* java/io/FileInputStream.java
(getChannel): Make it synchronized, rewrote implementation.
* java/io/FileOutputStream.java
(getChannel): Make it synchronized, rewrote implementation.
* java/io/RandomAccessFile.java
(getChannel): Make it synchronized, rewrote implementation.
Diffstat (limited to 'java/io/FileOutputStream.java')
-rw-r--r-- | java/io/FileOutputStream.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/java/io/FileOutputStream.java b/java/io/FileOutputStream.java index e7af997fd..938c55132 100644 --- a/java/io/FileOutputStream.java +++ b/java/io/FileOutputStream.java @@ -52,6 +52,8 @@ public class FileOutputStream extends OutputStream { private FileDescriptor fd; + private FileChannel ch; /* cached associated file-channel */ + /** * This method initializes a <code>FileOutputStream</code> object to write * to the named file. The file is created if it does not exist, and @@ -258,25 +260,17 @@ public class FileOutputStream extends OutputStream } /** - * This method creates a java.nio.channels.FileChannel. + * This method creates a java.nio.channels.FileChannel. * Nio does not allow one to create a file channel directly. * A file channel must be created by first creating an instance of * Input/Output/RandomAccessFile and invoking the getChannel() method on it. */ - - private FileChannel ch; /* cached associated file-channel */ - - public FileChannel - getChannel() + public synchronized FileChannel getChannel() { - synchronized (this) - { - // FIXME: Convert NIO to 64 bit - if (ch == null) - ch = new gnu.java.nio.FileChannelImpl( - (int)(fd.getNativeFd() & 0xFFFF), this); - } - return ch; + if (ch == null) + ch = new FileChannelImpl ((int) (fd.getNativeFd() & 0xFFFF), this); + + return ch; } } // class FileOutputStream |