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
33
votes
6 answers

What order should I use GzipOutputStream and BufferedOutputStream

Can anyone recommend whether I should do something like: os = new GzipOutputStream(new BufferedOutputStream(...)); or os = new BufferedOutputStream(new GzipOutputStream(...)); Which is more efficient? Should I use BufferedOutputStream at all?
sanity
  • 35,347
  • 40
  • 135
  • 226
19
votes
3 answers

What is the difference between GZIPOutputStream and DeflaterOutputStream?

GZIPOutputStream is just a subclass of DeflaterOutputStream but both can be instantiated. When do I use one over the other? Is the compression the same?
18
votes
6 answers

Force flush on a GZIPOutputStream in java

we are working on a program where we need to flush (force compress and send data) a GZIPOutputStream. The problem is, that the flush method of the GZIPOutputStream doesn't work as expected (force compress and send data), instead the Stream waits for…
Hemeroc
  • 2,176
  • 5
  • 23
  • 29
13
votes
3 answers

GZip in android

How to compress and decompress a file in android using GZip. please provide with some reference , so that it would a great help for me. Thanks in advance
Nandagopal T
  • 2,037
  • 9
  • 42
  • 54
12
votes
2 answers

String to GZIPOutputStream

I've tried searching and couldn't find anything. What I'm trying to do is I'm looping through a list where I'm constructing a string from a combination of items from multiple lists. I then want to dump these strings to a gzipped file. I got it…
dabuddha
  • 173
  • 1
  • 2
  • 7
10
votes
4 answers

Compressing with Java Decompressing with PHP

I have a situation where a servlet is providing compressed data to a PHP script. I compress the data on the Java side no problem, but PHP seems unable to decompress. Here is the relevent code snippets Java Side: OutputStream…
David Hamilton
5
votes
2 answers

Why do gzip of Java and Go get different results?

Firstly, my Java version: string str = "helloworld"; ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(str.length()); GZIPOutputStream localGZIPOutputStream = new…
kosmos
  • 63
  • 1
  • 6
5
votes
2 answers

Compressing unicode characters

I am using GZIPOutputStream in my java program to compress big strings, and finally storing it in database. I can see that while compressing English text, I am achieving 1/4 to 1/10 compression ration (depending on the string value). So say for…
Arry
  • 1,630
  • 9
  • 27
  • 46
5
votes
3 answers

GZIP decompress string and byte conversion

I have a problem in code: private static String compress(String str) { String str1 = null; ByteArrayOutputStream bos = null; try { bos = new ByteArrayOutputStream(); BufferedOutputStream dest = null; byte b[]…
Alexandr Erofeev
  • 53
  • 1
  • 1
  • 4
4
votes
1 answer

java wrap GZIPOutputStream & ByteArrayOutputStream together - what am I doing wrong?

Main.java import java.io.IOException; public class Main { private final CompressedOutputStream m_cos; public static void main(String[] args) { try { final Main m = new Main(new…
Poni
  • 11,061
  • 25
  • 80
  • 121
4
votes
2 answers

Compressing a string using GZIPOutputStream

I want to zip my string values. These string values should be same as .net zipped strings. I wrote Decompress method and when I send a .net zipped string to it, it works correctly. But the Compress method does not work correctly. public static…
Bob
  • 22,810
  • 38
  • 143
  • 225
4
votes
1 answer

Gzip decompression adding one extra byte ... Why?

I've written a simple Java code snippet which takes a String, converts it to byte[], and then compresses it using Gzip. Then it decompresses the result to get back the byte[], which now contains one extra garbage value byte. Why is there a garbage…
Ahmad
  • 12,886
  • 30
  • 93
  • 146
4
votes
3 answers

compressing with GZIPOutputStream to upload without creating a gzip file locally

I'm trying to compress the file in java before I upload the file with GZIPOutputStream. Is there a way to just store the gzipped file in memory for the upload and not have it generate a gzipped file on the local computer? Thanks!
4
votes
2 answers

GZIP eats newlines

I have the following code for compressing and decompressing string. public static byte[] compress(String str) { try { ByteArrayOutputStream obj = new ByteArrayOutputStream(); GZIPOutputStream gzip = new…
Quillion
  • 6,346
  • 11
  • 60
  • 97
4
votes
2 answers

GZIPOutputStream that does its compression in a separate thread

Is there an implemetation of GZIPOutputStream that would do the heavy lifting (compressing + writing to disk) in a separate thread? We are continuously writing huge amounts of GZIP-compressed data. I am looking for a drop-in replacement that could…
krlmlr
  • 25,056
  • 14
  • 120
  • 217
1
2 3 4 5 6