title: How do I list file names on a server in a directory?
body: <p>I am trying to get the names of all the directories and files that inside the <code>tpo</code> directory on some server but
  as I run the following code:</p>
  
  <pre><code>public static void main(String args[]) {
      try {
          File file = new File(new URI("http://xxx/tpo/"));
          String list[] = file.list();
          for(String name : list) {
              System.out.println(name);
          }
      }catch(Exception exc) {
          exc.printStackTrace();
       }
  }
  </code></pre>
  
  <p>I get the following exception :</p>
  
  <pre><code>java.lang.IllegalArgumentException: URI scheme is not "file"
  at java.io.File.&lt;init&gt;(File.java:366)
  at hack.List.main(List.java:17)
  </code></pre>
  
  <p>Why is that ? How do I get the file names and the names of the directories inside the <code>tpo</code> directory.</p>