I would use something like the following:
ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); GZipOuputStream gzipOut = new GZipOutputStream(byteOut);
You write the zip values ββto the byte stream, and then take the byte values, you can write them to another stream. You can also transfer the stream to the amazon site (i.e., the Output stream from the http connection or something similar) and avoid all ByteArrayOutputStream.
Edit: I noticed your last suggestion is bleah. You can take the bytes you created, create a ByteArrayInputStream with them, and then pass this as input:
ByteArrayInputStream byteInStream = new ByteArrayInputStream(bites);
It should read from the input stream to the output stream, if I understand what you are describing correctly. Otherwise, you can simply write the output stream.
source share