title: Creating a Java InputStream from an Enumerator[Array[Byte]]
body: <p>I've been reading up a lot on Iteratees &amp; Enumerators in order to implement a new module in my application.</p>
  
  <p>I'm now at a point where I'm integrating with a 3rd party Java library, and am stuck at working with this method:</p>
  
  <pre><code>public Email addAttachment(String name, InputStream file) throws IOException {
      this.attachments.put(name, file);
      return this;
  }
  </code></pre>
  
  <p>What I have in my API is the body returned from a <code>WS</code> HTTP call that is an <code>Enumerator[Array[Byte]]</code>.</p>
  
  <p>I am wondering now how to write an <code>Iteratee</code> that would process the chunks of <code>Array[Bytes]</code> and create an <code>InputStream</code> to use in this method.</p>
  
  <p><em>(Side bar): There are other versions of the <code>addAttachment</code> method that take <code>java.io.File</code> however I want to avoid writing to the disk in this operation, and would rather deal with streams.</em></p>
  
  <p>I attempted to start by writing something like this:</p>
  
  <pre><code>Iteratee.foreach[Array[Byte]] { bytes =&gt;
      ???
  }
  </code></pre>
  
  <p>However I'm not sure how to interact with the java <code>InputStream</code> here. I found something called a <a href="http://docs.oracle.com/javase/6/docs/api/java/io/ByteArrayInputStream.html"><code>ByteArrayInputStream</code></a> however that takes the entire <code>Array[Byte]</code> in its constructor, which I'm not sure would work in this scenario as I'm working with chunks ?</p>
  
  <p>I probably need some Java help here!</p>
  
  <p>Thanks for any help in advance.</p>