title: Idiomatic way of mapping across Optional with void method
body: <p>I have a <code>Optional</code> and want to call a function with its' contents if present, and throw if not. The problem is <code>map</code> will not take a void method.</p>
  
  <pre><code>    File file;
      //...
      Optional maybeFile  = Optional.ofNullable(file);
      //..
      maybeFile
          .map(f -&gt; writeTo(f, "stuff")) //Compile error: writeTo() is void
          .orElseThrow(() -&gt; new IllegalStateException("File not set"));
  </code></pre>
  
  <p>How should I implement this while keeping <code>writeTo</code> void?</p>