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

java.io.File.{list,listFiles}(null) returns null

XMLWordPrintable

    • 1.2fcs
    • sparc
    • solaris_2.5.1
    • Verified



      Name: akC57697 Date: 05/21/98



      The java.io.File.list(null) returns null.

      The doc:
      " .....
        If the given filter is null then all names are accepted.
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        Otherwise, a name satisfies the filter if and only if the value
        true results when the FilenameFilter#accept method of the filter
        is invoked on this abstract pathname and the name of a file or
        directory in the directory that it denotes.
        @return ... The array will be empty if
                 the directory is empty or if no names were accepted by the
                 filter. Returns null if this abstract pathname
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 does not denote a directory, or if an I/O error occurs.
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        .....
      "

      The source code of java.io.File "@(#)File.java 1.70 98/05/13" :
      "
          public String[] list(FilenameFilter filter) {
      String names[] = list();
      if ((names == null) || (filter == null)) { <--
      return null;
      }
          ...
      "
      ---------------------8-<----------------------
      import java.io.File;
      public class Test {
          public static void main(String s[]) {
       
        try {
         File l=new File("/");
         System.out.println("The list: "+l.list(null));
        } catch (Exception e) { System.out.println(e);}
         }
      }
      --------------------->-8----------------------
      Output:
      (###@###.###): java -fullversion
      java full version "JDK-1.2beta4-F"
      (###@###.###): java Test
      The list: null

      ======================================================================

            mr Mark Reinhold
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: