title: navigate directory structure and name each processed file uniquely
body: <p>I have a directory structure of the form <code>start</code><strong>/</strong><code>one</code><strong>/</strong><code>two</code><strong>/</strong><code>three</code><strong>/</strong><code>*files*</code></p>
  
  <p>My goal is to construct this program such that it can navigate my directory structure autonomously, grab each file then process it, which it seems to be doing correctly. </p>
  
  <p><strong>BUT</strong> I also need the output to be written to a new file with a unique name, i.e. the file named <code>00001.txt</code> should be processed and the results should be written to <code>00001_output.txt</code></p>
  
  <p>I thought I implemented that correctly but, apparently not. </p>
  
  <p>Where have I gone astray? </p>
  
  <pre><code>    String dirStart = "/home/data/";
  
      Path root = Paths.get(dirStart);
  
      Files.walkFileTree(root.toAbsolutePath().normalize(), new SimpleFileVisitor&lt;Path&gt;() 
      {
          @Override
          public FileVisitResult visitFile(Path file, java.nio.file.attribute.BasicFileAttributes attrs) throws IOException 
          {
  
  
              try(InputStream inputStream = Files.newInputStream(file);
                      BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)))
              {
  
                  // CHANGE OUTPUT TO NEW FILE
                  String print_file = file.getFileName().toString();
                  String fileNameWithOutExt = FilenameUtils.removeExtension(print_file);
                  System.out.println(fileNameWithOutExt);
  
                  PrintStream out = new PrintStream(new FileOutputStream( fileNameWithOutExt + "_output.txt" ) );
                  System.setOut(out);
  
  
                  // SOUP PART
                  StringBuilder sb = new StringBuilder();
                  String line = bufferedReader.readLine();
  
                  while (line != null) 
                  {
  
                      sb.append(line);
                      sb.append(System.lineSeparator());
                      line = bufferedReader.readLine();
                  }
                  String everything = sb.toString();
  
  
                  Document doc = Jsoup.parse(everything);
                  String link = doc.select("block.full_text").text();
                  System.out.println(link);
  
  
              } 
              catch (IOException e) 
              {
                  e.printStackTrace();
              }
  
              return FileVisitResult.CONTINUE;
          }
      }); 
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/29740116/run-a-java-program-on-multiple-files-in-a-directory-output-with-unique-names">This</a> is also my question, it might give some additional insight on what I'm actually trying to do. </p>