Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4427862

java.io.FileInputStream fails when argument has trailing slash (Linux)

XMLWordPrintable

    • rc1
    • generic
    • generic
    • Verified


            import java.io.*;

            public class F {

        public static void main(String[] args) throws Exception {
        String fn = "/etc/passwd/";
        new FileInputStream(fn);
        }

            }

        This program works fine on Solaris, but fails on Linux:

            % java F
            Exception in thread "main" java.io.FileNotFoundException: /etc/passwd/ (Not a directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java, Compiled Code)
        at F.main(F.java:15)
            %

        This is reproducible in 1.2.2, 1.3.0, and 1.3.1-beta.

        -- mr@eng 2001/3/20
        =======================================================

        A regression test that demonstrates this is:
        java/io/pathNames/GeneralSolaris.java
        java/io/pathNames/unix/TrailingSlash.java
        al.smith@eng 2001-03-26

              mr Mark Reinhold
              mr Mark Reinhold
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: