title: Lowest impact method of getting size from InputStream
body: <p>I am trying to get the size of an InputStream for use as a comparison against a file transfer, to ensure that all file data is transferred. I'm using Jcraft's ChannelSftp and SftpProgressMonitor, but <code>SftpProgressMonitor.init()</code> does not provide <code>max</code> for InputStreams, so I'd like to find it internally.</p>
  
  <p>At this point in the system, I know that the InputStream will not be written to any further, I can't easily access the original file to read that size, and I've seen many of the other implementations that read into a byte array or ByteArrayOutputStream. What method would have the least overall impact on the system if I want to maintain an InputStream for the actual SFTP calls? The files being written can be quite large (into 1+ GB) so a simple implementation might have significant impact.</p>