title: Getting an InputStream of Writer using standard Java library
body: <p>I have an method which writes data to an OutputStream but needs to  return the contents of the OutputStream as an InputStream </p>
  
  <pre><code>public InputStream getInputStreamOfData(type param) {
      // ..... data 
      OutputStreamWriter writer = new OutputStreamWriter();
      writer.write(data);
      // convert writer object to an InputStream 
  }
  </code></pre>
  
  <p>I came across some libraries to do this such as IOUtils and other thread based methods. Is there a simple way to achieve this using standard Java library ? I want to return the contents in the writer as an InputStream to be consumed by the calling method. </p>
  
  <p>Thanks!</p>