title: The correct way to use FileVisitor in java
body: <p>I am trying to step through an entire path and its single layer of sub directories. For each file, I need to read five data fields and output them to a delimited text file. I'm able to read from a <strong>single</strong> text file and validate my output on screen; after that I'm stuck. I cannot seem to to find the right parameters for FileVisit. Some specific questions are comments in my code posted below. And although I'm no nearly that far yes, I'd like to get some idea for writing to an output file, namely whether the place I wish to put it is the most logical one. </p>
  
  <p>I've reviewed the <a href="https://stackoverflow.com/questions/9913/java-file-io-compendium">https://stackoverflow.com/questions/9913/java-file-io-compendium</a> and JavaDocs' info on the File Visitor<br>
  <a href="http://docs.oracle.com/javase/7/docs/api/index.html?java/nio/file/FileVisitor.html" rel="nofollow noreferrer">http://docs.oracle.com/javase/7/docs/api/index.html?java/nio/file/FileVisitor.html</a> .
  However, I'm still not able to get FileVisitor working properly.</p>
  
  <p>@Bohemian suggested changing <code>interface</code> to <code>class</code> which I've done.</p>
  
  <pre><code> import java.nio.files.*;
   public class FileVisitor&lt;T&gt; 
   {
        Path startPath = Paths.get("\\CallGuidesTXT\\");
        Files.walkFileTree(startPath, new SimpleFileVisitor(startPath))
        \\             ^^^^^^    
        \\ errors out, &lt;identifier expected&gt;          
            { 
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
                throws IOException
            {
                Files.list(file);
                return FileVisitResult.CONTINUE;
            }
          // do my file manipulations here, then write the delimited line 
          // of text to a CSV fle...is this the most appropriate place for that 
          // operation in this sample? 
        }  
   }
  </code></pre>
  
  <p>SSCCE below...but comments in the version above point to specific questions I'm having.</p>
  
  <pre><code> import java.nio.*;
   import java.util.*;
   public class FileVisitor&lt;T&gt;
   {
      Path startPath = Paths.get("\\CallGuidesTXT\\");
   }
   Files.walkFileTree(startPath, new SimpleFileVisitor(startPath)  {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
            throws IOException {
            Files.list(file);
            return FileVisitResult.CONTINUE;
        } 
   });
  </code></pre>