title: Add callback function to Java stream
body: <p>Let's say I want to perform the following operations:</p>
  
  <ul>
  <li>List the files in a given directory (as a stream)</li>
  <li>Map each file (Path) into a Reader (BufferedReader for example) for a consumer to consume.</li>
  <li>Once a file has been consumed, delete the files</li>
  </ul>
  
  <p>The code would look a bit like this:</p>
  
  <pre><code>Stream&lt;Reader&gt; stream = Files.list(Paths.get("myFolder")) // Returns a stream of Path
    .callback(Files::delete)                                // This would have to be called after the reader has been consumed
    .map(Files::newBufferedReader);                         // Maps every path into a Reader
  </code></pre>
  
  <p>If I use <code>peek()</code> to delete the files, then the file won't be there when it needs to be mapped into a Reader, so I'd need something that runs after the stream is consumed. 
  Any idea?</p>