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
3
votes
1 answer

Java GZIPOutputStream appears to allocate unnecessary byte arrays?

I have an application that processes text files and stores them and to save some space it gzips the files. So I have some chained OutputStreams and one of them is java.util.zip.GZIPOutputStream that manages the compression. To make sure I was not…
Gyst
  • 101
  • 1
  • 5
3
votes
1 answer

How to Reduce the time of GZIPOutputStream

I have tried to gzip a large(100mb to 500mb) xml file.I have created method Zip to do that. the issues is that its talking too much time to zip.for 200mb it take 1.2 secs.i need to reduce the time too 100 millisecond for 100mb xml file. how do i…
3
votes
2 answers

Using GZIPOutputStream to send a compressed chunk in java

I'm trying to send a compressed HTML file through a java socket but the browser displays an empty HTML file. The thing is, when I try to send the uncompressed HTML everything works find (yes I do modify the HTTP headers accordingly). private void…
Gogol31
  • 33
  • 1
  • 4
3
votes
1 answer

java.io.IOException: request to write '' bytes exceeds size in header of '' bytes for entry ''

I am creating a tar.Gzip file using GZIPOutputStream and I have added an another logic in that if any Exception caught while compressing file then, my code will retry three times. When I am throwing an IOException to test my retry logic it throwing…
Ashish Pancholi
  • 4,569
  • 13
  • 50
  • 88
2
votes
2 answers

GZIPOutputStream not properly compressing a String for HTTP Response

I'm writing a simple Java http server that responds with JSON data. I'm trying to GZip the data before sending it, but it usually sends back gzipped data that produces an error in the browser. For example, in Firefox it says: Content Encoding…
DFx
  • 249
  • 3
  • 14
2
votes
1 answer

Java: CRC error when using setDictionary for GZIPOutputStream's Deflater

I'm trying to take a stream of data from standard in, compress it one 128 byte block at a time, and then output it to standard out. (Example: "cat file.txt | java Dict | gzip -d | cmp file.txt", where file.txt just contains some ASCII characters.) I…
Kami's Aibou
  • 327
  • 4
  • 13
2
votes
0 answers

Why does zcat throw "invalid compressed data" when decompressing a file compressed with GzipOutputStream?

In C++, I use the GzipOutputStream to compress the data, which is a big string. At first, I have to convert the string to a proto message, like this: syntax = "proto3"; package Serverlog_Compress; message ServerlogMessage { string data =…
2
votes
1 answer

performance of GZIPOutputStream vs BufferedOutputStream

my application is logging a shitload of video and i2c sensor data into a disk file - as fast as possible. Currently I am converting everything to bytes and i am writing with a BufferedOutputStream. @Siguza was kind enough to suggest looking into a…
Robert Huber
  • 92
  • 11
2
votes
1 answer

Java - Compress large string

In my Java application I get from some calculations a really long string (from really long string I mean of around 600000 characters or so). But I need to send this string to a client to process it, and for this reason I need the compressed string…
Ernestina Juan
  • 957
  • 1
  • 9
  • 24
2
votes
1 answer

Do I need to call finish() when using a GZIPOutputStream object inside try-wtth-resources block

When using a GZipOutputStream inside of a try-with-resources [autoclosable] block, do I need to explicitly call finish() after I'm done with my resource?
NathanChristie
  • 2,374
  • 21
  • 20
2
votes
1 answer

BufferedOutputStream multiple lines Write in File

I have a little problem with a function I made. I want that everytime I give a string to this function, it will save me to a new Line in the same file, but actually now is saving only the last string Im givving. It's like overwriting again and…
Nicholas
  • 3,529
  • 2
  • 23
  • 31
2
votes
4 answers

Count the bytes written to file via BufferedWriter formed by GZIPOutputStream

I have a BufferedWriter as shown below: BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new GZIPOutputStream( hdfs.create(filepath, true )))); String line = "text"; writer.write(line); I want to find out the bytes…
Junaid
  • 768
  • 8
  • 13
2
votes
1 answer

send GZIP stream over WCF

Below is my code. I set the content-encoding header. Then write the file stream, to memory stream, using gzip encoding. Then finally return the memory stream. However, the android, IOS, and webbrowser all recieve corrupt copies of the stream. None…
Mcloving
  • 1,390
  • 1
  • 13
  • 30
1
vote
1 answer

Why my compressed output using GZIPOutputStream is not matching when we decompressed the same string using any online compression tools

I am using below code to compress my test string into gzip format 'private static final String TEST_STRING = "Test String"; public static void main(String[] args) throws IOException { System.out.println("Original data: " + TEST_STRING); …
Vaibhav
  • 169
  • 6
1
vote
1 answer

How to create a GZIP file in Java from another file without creating a new physical file

I was working with this example: public class GZipExample { public static void main(String[] args) { // compress a file Path source = Paths.get("/home/test/sitemap.xml"); Path target =…
user1472672
  • 313
  • 1
  • 9