title: File.list() vs File.listFiles()
body: <p>My question is: if this two functions have something different? I mean I know that they return something different, but is it possible that number of elements in one would be different then in the second one. I will try to explain. I implemented TreeModel for one of my class trying to make nice view on files on the PC basing on JTree. So here is the part of it:</p>
  
  <pre><code>public Object getChild(Object parent, int index) {
          File[] children = ((File) parent).listFiles();
          if(children == null || index &lt; 0 || index &gt;= children.length) {
              return null;
          }
  
          File result = new MyFile(children[index]);
          return result;
  }
  
  public int getChildCount(Object parent) {
          //---
          //String[] children = ((File)parent).list();
          File[] children = ((File)parent).listFiles();
          //---
  
          if(children == null) {
              return 0;
          }
          return children.length;
  }
  </code></pre>
  
  <p>I marked interesting code. If I changed this two lines for this commented one, sometimes I get <code>NullPointerException</code> after loading TreeModel: <code>jtree.setModel(treeModel);</code>. This uncommented does not cause any trouble. I checked the docs and it says nothing unusual including returning null by both methods. What is going on here?</p>