OSDN Git Service

Merged gcj-eclipse branch to trunk.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / java / io / FileInputStream.java
index 8ca38b0..8217668 100644 (file)
@@ -38,8 +38,9 @@ exception statement from your version. */
 
 package java.io;
 
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.FileChannelImpl;
 
+import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 
 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
@@ -107,7 +108,20 @@ public class FileInputStream extends InputStream
     if (s != null)
       s.checkRead(file.getPath());
 
-    ch = FileChannelImpl.create(file, FileChannelImpl.READ);
+    try
+      {
+        ch = FileChannelImpl.create(file, FileChannelImpl.READ);
+      }
+    catch (FileNotFoundException fnfe)
+      {
+        throw fnfe;
+      }
+    catch (IOException ioe)
+      {
+        FileNotFoundException fnfe = new FileNotFoundException(file.getPath());
+        fnfe.initCause(ioe);
+        throw fnfe;
+      }
   }
 
   /**
@@ -266,7 +280,7 @@ public class FileInputStream extends InputStream
         || offset + len > buf.length)
       throw new ArrayIndexOutOfBoundsException();
 
-    return ch.read(buf, offset, len);
+    return ch.read(ByteBuffer.wrap(buf, offset, len));
   }
 
   /**