Questions tagged [gzipoutputstream]

GzipOutputStream is a Java class for writing data that will be compressed in gzip format. It is also available on Android.

GzipOutputStream is a Java class for writing data that will be compressed in gzip format. It is also available on Android.

On .NET, there is a similar class called GZipStream: use

90 questions
1
vote
0 answers

Is bytearrayoutputstream wrapped in GZIPOutputStream blocking operation

val baos = new ByteArrayOutputStream(input.size) val gzipOut = new GZIPOutputStream(baos) try { gzipOut.write(input.getBytes("UTF-8"), 0, input.length) gzipOut.finish() } finally { gzipOut.close() } baos.toByteArray I am trying to compress…
1
vote
2 answers

Is GZIPOutputStream known to loose data during compression?

I have a very strange issue with GZIPOutputStream when compressing an array of doubles. At the 57th element, I get a small discrepancy when I reload the data: 57 > 3.003727492141554E7 3.0037273913440887E7 1900: false 57 > -6.110783629228158E7…
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
1
vote
1 answer

Is it possible to exclude files and/or directories when using GZIPOutputStream or ZIPOutputStream in java?

I am trying to archive all the files in the root directory of the folder but have the backups as one of the folders in the root directory so I wanted to exclude it so each backup after the first one isn't backing up the backups folder (aka…
JordanPlayz158
  • 81
  • 1
  • 11
1
vote
1 answer

Closing GZIPOutputStream after ByteStream copy in finally block break zip

I have code which Zip and Unzip Text. I'm facing weird behavior - only when I close the GZIPOutputStream in certain place, the code works but when I try to place the GZIPOutputStream close in the finally block, it breaks and does not work. If you…
user63898
  • 29,839
  • 85
  • 272
  • 514
1
vote
1 answer

How to do GZIP compression while writing directly to response

I am trying to compress my response when the request header contains gzip in Accept-Encoding. However, adding following to app.properties only works when controller method is returning an…
1
vote
2 answers

GZipOutputStream & appengine

I'm writing a java servlet on AppEngine. This servlet generates png images. I would like to "gzip" the response. I do it this way: resp.setHeader("Content-Encoding","gzip"); resp.setContentType("image/png"); // ... png generation…
Francois
  • 10,730
  • 7
  • 47
  • 80
1
vote
2 answers

GZIPInputStream unable to decode at receiver side (invalid code lengths set)

I'm attempting to encode a String in a client using GZIPOutputStream then decoding the String in a server using GZIPOutputStream. The client's side code (after the initial socket connection establishment) is: // ... Establishing connection, getting…
amirkr
  • 173
  • 3
  • 15
1
vote
0 answers

How to gzip then unzip a string without going to the filesystem in Java?

Desired: Create compress and uncompress a string or byte array. After that I plan to Base64 encode it for writing to a log file. Unfortunately, it looks like it is not recognizing it as being compressed or something. I'm assuming that it is missing…
ScrappyDev
  • 2,307
  • 8
  • 40
  • 60
1
vote
2 answers

How can I gzip an InputStream and return an InputStream?

I am starting with a response from a HTTP request: InputStream responseInputStream = response.getEntityInputStream() I need to gzip that response so I can upload it to s3 and save it compressed: this.s3.putObject(new PutObjectRequest(bucketName,…
chaimp
  • 16,897
  • 16
  • 53
  • 86
1
vote
1 answer

How to compress a .zip to a .gz in java?

I want to compress a normal file to a .zip and then compress it as gzip file without creating a new file. For example let's say that I have a pdf document doc.pdf, what I have to get is: doc.pdf.zip.gz I don't want to creat a new file called…
1
vote
0 answers

Error: Not in GZIP format - attempt to decompress GZIP stream previously stored in a database field

Streaming confuses me - just when I think I'm grasping the idea, my code goes belly up. I'm attempting to take in a string, gzip compress it, and store it in a PostGreSQL database. THEN I want to get it back out and re-transform it into an output…
1
vote
0 answers

Sending files over a RESTful webservice: Base64 encoding and GZip compression

Since a few days I am fiddling with Java a project to send/receive files with a RESTful webservice. I do this with as little extra libraries as possible because this will be an extension to an existing software system. To make my project run within…
Vertongen
  • 185
  • 3
  • 14
1
vote
1 answer

NIO GZIP compression and copying of files

I was using FileChannel and FileInputStream to do a simple file copying from File fromFile to File toFile. The code is basically like this: source = new FileInputStream(fromFile).getChannel(); destination = new FileOutputStream(toFile,…
bozeng
  • 245
  • 1
  • 2
  • 10
1
vote
1 answer

Gzip a string in Zlib using C/C++

I would like to use gzip from C++ (or C) to gzip a string. If possible, I would like to use zlib. When I learned that I would have to use zlib to compress and uncompress, I Googled it for a few minutes and then quickly wrote a program to gzip a file…
Uday
  • 43
  • 1
  • 4
1
vote
1 answer

How can I convert a string into a GZIP Base64 string with ByteArrayOutputStream?

I need to convert string to gzip base64. I have this code import java.util.zip.GZIPOutputStream; import org.apache.commons.codec.binary.Base64OutputStream; public class Test { public static void main(String[] args) { String text = "a…
Igor Ussov
  • 31
  • 3