Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6216529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:15:51+00:00 2026-05-24T07:15:51+00:00

I need to compress/decompress different types of files that are contained in a Folder

  • 0

I need to compress/decompress different types of files that are contained in a Folder the size of that folder might be more than 10-11 GB.
I used following code but this is taking long time to compress the data.

BufferedReader in = new BufferedReader(new FileReader("D:/ziptest/expansion1.MPQ"));
BufferedOutputStream out = new BufferedOutputStream(
    new GZIPOutputStream(new FileOutputStream("test.gz")));

int c;
while ((c = in.read()) != -1)
  out.write(c);
in.close();
out.close();

Please suggest me some fast compressing and decompressing library in java, i also want to split the large file in different parts such as in a chunk of 100MB each.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:15:51+00:00Added an answer on May 24, 2026 at 7:15 am

    Reader/Writer is only for Text and if you try to read binary with these is will get corrupted.

    Instead I suggest you use FileInputStream. The fastest way to copy the data is to use your own buffer.

    InputStream in = new FileInputStream("D:/ziptest/expansion1.MPQ");
    OutputStream out = new GZIPOutputStream(
                new BufferedOutputStream(new FileOutputStream("test.gz")));
    
    byte[] bytes = new byte[32*1024];
    int len;
    while((len = in.read(bytes)) > 0)
       out.write(bytes, 0, len);
    
    in.close();
    out.close();
    

    Since you reading large chunks of bytes, it is more efficient not to BufferedInput/OuptuStream as this removes one copy. There is a BufferedOutptuStream after the GZIPOutputStream as you cannot control the size of data it produces.

    BTW: If you are only reading this with Java, you can use DeflatorOutputStream, its slightly faster and smaller, but only supported by Java AFAIK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have around 2 million strings with different lengths that I need to compress
From MSDN: DeflateStream Class DeflateStream cannot be used to compress files larger than 4 GB.
I've got some strings that I need to compress server-side in C#, then decompress
I need to write a program to compress/decompress txt files using Huffman algotrithm I
I need to compress folder with files in .7z format. I use SevenZip for
I need to compress some binary files as quickly as possible with PHP -
I need to compress a string to reduce the size of a web service
I'm developing an application that will need to communicate with itself running on different
I need compress library for following needs: 1) Packing directory in one file with
I need to compress a Visual Studio 2010 Solution into zipped folder, so I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.