Checking InputStream.available only reports the bytes immediately available without blocking--not whether or not the stream has been completely read. Please see https://github.com/wavefrontHQ/wavefront-sdk-java/pull/347 for one approach to copy an InputStream to an OutputStream.