title: Determine the size of an InputStream
body: <p>My current situation is: I have to read a file and put the contents into <code>InputStream</code>. Afterwards I need to place the contents of the <code>InputStream</code> into a byte array which requires (as far as I know) the size of the <code>InputStream</code>. Any ideas?</p>
  
  <p>As requested, I will show the input stream that I am creating from an uploaded file</p>
  
  <pre><code>InputStream uploadedStream = null;
  FileItemFactory factory = new DiskFileItemFactory();
  ServletFileUpload upload = new ServletFileUpload(factory);
  java.util.List items = upload.parseRequest(request);      
  java.util.Iterator iter = items.iterator();
  
  while (iter.hasNext()) {
      FileItem item = (FileItem) iter.next();
      if (!item.isFormField()) {
          uploadedStream = item.getInputStream();
          //CHANGE uploadedStreambyte = item.get()
      }
  }
  </code></pre>
  
  <p>The request is a <code>HttpServletRequest</code> object, which is like the <code>FileItemFactory</code> and <code>ServletFileUpload</code> is from the Apache Commons FileUpload package.</p>