title: Traversing files and directories using Java
body: <p>I have a small code wich can return the list of files under any directory.</p>
  
  <p>What I need to do is get the <code>Directories</code> and <code>Files</code> under the first given directory.</p>
  
  <p>This is the code I'm using.</p>
  
  <pre><code>    File dir = new File("C:/myDocument/myFolder");
  
      String[] children = dir.list();
      if (children == null) {
  
      } else {
          for (int i=0; i&lt;children.length; i++) {
  
              String filename = children[i];
              System.out.println(filename);
          }
      }
  </code></pre>
  
  <p>Another thing is when I select the path from Windows 7, I get this <code>C:\myFolder\myFolder</code>.
  If I use this path in Java I get this error <code>Invalide Escape sequence</code>
  Do I have to change it to <code>C:/myDocument/myFolder</code> to get it work.</p>
  
  <p>Help.</p>
  
  <p>Thanks</p>