summaryrefslogtreecommitdiffstats
path: root/libjava
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-20 07:54:24 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-20 07:54:24 +0000
commitff0263c808951d22e7f0324fd28877cf4f6a1fab (patch)
treec99af8765e9410ed162e184496445f198dee0afc /libjava
parent2653f9df5503bdf69f827ea82909a623484605a3 (diff)
downloadppe42-gcc-ff0263c808951d22e7f0324fd28877cf4f6a1fab.tar.gz
ppe42-gcc-ff0263c808951d22e7f0324fd28877cf4f6a1fab.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64609 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog13
-rw-r--r--libjava/java/io/FileInputStream.java9
-rw-r--r--libjava/java/io/FileOutputStream.java16
-rw-r--r--libjava/java/io/RandomAccessFile.java19
4 files changed, 50 insertions, 7 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 6c0821ececc..7e368570992 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,18 @@
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,
java/io/File.java,
java/io/FileInputStream.java,
diff --git a/libjava/java/io/FileInputStream.java b/libjava/java/io/FileInputStream.java
index bbc7f7c6840..dcda9d81e64 100644
--- a/libjava/java/io/FileInputStream.java
+++ b/libjava/java/io/FileInputStream.java
@@ -34,6 +34,7 @@ exception statement from your version. */
package java.io;
import java.nio.channels.FileChannel;
+import gnu.java.nio.FileChannelImpl;
/**
* @author Warren Levy <warrenl@cygnus.com>
@@ -124,6 +125,12 @@ public class FileInputStream extends InputStream
public FileChannel getChannel ()
{
- return ch;
+ synchronized (this)
+ {
+ if (ch == null)
+ ch = new FileChannelImpl (fd, false, this);
+
+ return ch;
+ }
}
}
diff --git a/libjava/java/io/FileOutputStream.java b/libjava/java/io/FileOutputStream.java
index 1154a4b2806..eaf4d9beaa2 100644
--- a/libjava/java/io/FileOutputStream.java
+++ b/libjava/java/io/FileOutputStream.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.io;
import java.nio.channels.FileChannel;
+import gnu.java.nio.FileChannelImpl;
/**
* @author Tom Tromey <tromey@cygnus.com>
@@ -147,11 +148,18 @@ public class FileOutputStream extends OutputStream
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;
}
diff --git a/libjava/java/io/RandomAccessFile.java b/libjava/java/io/RandomAccessFile.java
index d0192829e83..32d26877ed3 100644
--- a/libjava/java/io/RandomAccessFile.java
+++ b/libjava/java/io/RandomAccessFile.java
@@ -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;
}
OpenPOWER on IntegriCloud