2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
authorGuilhem Lavaux <guilhem@kaffe.org>
Fri, 26 Dec 2003 21:11:03 +0000 (21:11 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Fri, 26 Dec 2003 21:11:03 +0000 (21:11 +0000)
* java/io/FileInputStream.java
(FileInputStream(String)): Call FileInputStream(File).
(FileInputStream(File)): Check whether the argument is a directory.

From-SVN: r75039

libjava/ChangeLog
libjava/java/io/FileInputStream.java

index d566535d8c139db99c897a95342f6d16ccf4d0c7..fd7b37b6d647ade892a7241f450d67496dd52df8 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-26  Guilhem Lavaux  <guilhem@kaffe.org>
+
+       * java/io/FileInputStream.java
+       (FileInputStream(String)): Call FileInputStream(File).
+       (FileInputStream(File)): Check whether the argument is a directory.
+
 2003-12-26  Michael Koch  <konqueror@gmx.de>
 
        * Makefile.am (rmi_java_source_files):
index 4c599d11d1b2bb187c9814d3d407177a67c87355..c88f83db445cb7b1c798f2eb3b4f05a5a941d7ad 100644 (file)
@@ -79,11 +79,7 @@ public class FileInputStream extends InputStream
    */
   public FileInputStream(String name) throws FileNotFoundException
   {
-    SecurityManager s = System.getSecurityManager();
-    if (s != null)
-      s.checkRead(name);
-
-    fd = new FileDescriptor(name, FileDescriptor.READ);
+    this(new File(name));
   }
 
   /**
@@ -104,7 +100,14 @@ public class FileInputStream extends InputStream
    */
   public FileInputStream(File file) throws FileNotFoundException
   {
-    this(file.getPath());
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkRead(file.getPath());
+
+    if (file.isDirectory())
+      throw new FileNotFoundException(file.getPath() + " is a directory");
+
+    fd = new FileDescriptor(file.getPath(), FileDescriptor.READ);
   }
 
   /**