title: How do I read bytes from InputStream?
body: <p>I want to test that the bytes I write to <code>OutputStream</code>(a file OuputStream) is same as I read from same <code>InputStream</code>.</p>
  
  <p><strong>Test</strong> looks like </p>
  
  <pre><code>  @Test
      public void testStreamBytes() throws PersistenceException, IOException, ClassNotFoundException {
          String uniqueId = "TestString";
          final OutputStream outStream = fileService.getOutputStream(uniqueId);
          new ObjectOutputStream(outStream).write(uniqueId.getBytes());
          final InputStream inStream = fileService.getInputStream(uniqueId);
      }
  </code></pre>
  
  <p>I realized that <code>InputStream</code> doesn't have <code>getBytes()</code>.</p>
  
  <p>How can I test something like  </p>
  
  <pre><code>assertEquals(inStream.getBytes(), uniqueId.getBytes())
  </code></pre>
  
  <p>Thank you</p>