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 8104989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:03:13+00:00 2026-06-06T00:03:13+00:00

I have made an application in android that lets the user compress and decompress

  • 0

I have made an application in android that lets the user compress and decompress files and I used the package java.util.zip. Everything is okay. the speed, files are totally compressed and decompressed together with the directories. The only problem is that the application is not able to compress/decompress large files (greater than 1gb).

I believe the problem is the size of my buffer. Other codes that I’ve seen, the value of their buffer is 1024 or 2048 or 8192 but my value of my buffer is base on the size of the chosen file (just to make it flexible). But once the user chose a large file (with a size of >8 digits), that’s were the error comes out. I searched over the net and also here in this site but I can’t find an answer. my problem is similar to this:

To Compress a big file in a ZIP with Java

Thanks for the future help! 🙂

EDIT:

Thanks for the comments and answers. It really helped a lot. I thought BUFFER in compressing/decompressing in java means the size of file so in my program, I made the buffer size flexible (buffer size = file size). Will someone please explain how buffer works so I can understand why is it okay that BUFFER has a fixed value. Also for me to figure it out why others people is telling that it is much better if the buffer size is 8k or else. Thanks a lot! 🙂

  • 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-06-06T00:03:15+00:00Added an answer on June 6, 2026 at 12:03 am

    If you size the buffer to the size of the file, then it means that you will have OutOfMemoryError whenever the file size is too big for memory available.

    Use a normal buffer size and let it do it’s work – buffering the data in a streaming fashion, one chunk at a time, rather than all in one go.

    For explanation, see for example the documentation of BufferedOutputStream:

    The class implements a buffered output stream. By setting up such an
    output stream, an application can write bytes to the underlying output
    stream without necessarily causing a call to the underlying system for
    each byte written.

    So using a buffer is more efficient than non-buffered writing.

    And from the write method:

    Ordinarily this method stores bytes from the given array into this
    stream’s buffer, flushing the buffer to the underlying output stream
    as needed. If the requested length is at least as large as this
    stream’s buffer, however, then this method will flush the buffer and
    write the bytes directly to the underlying output stream.

    Each write causes the in-memory buffer to fill up, until the buffer is full. When the buffer is full, it is flushed and cleared. If you use a very large buffer, you will cause a large amount of data to be stored in memory before flushing. If your buffer is the same size as the input file, then you are saying you need to read the whole content into memory before flushing it. Using the default buffer size is usually just fine. There will be more physical writes (flushes); you avoid exploding memory.

    By allowing you to specify a specific buffer size, the API is letting you choose the right balance between memory consumption and i/o to suit your application. If you tune your application for performance, you might end up tweaking buffer size. But the default size will be reasonable for many situations.

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

Sidebar

Related Questions

I have made an application that gives the user the option to open up
I have used an Android application recently that has an interesting UI pattern in
I am new to android world. I have made an application of a user
I have made a ListView in my android application. But the problem is that
I have made a Android streaming application that plays media from online URL's. For
I am using the XMPP Connection(using smack) for chat in android application.I have made
I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it
i have made an android application for Project Build Target as Target name:: Android
I have developed and Simple android application in Java and also uploaded it on
I have a little problem... I have made an Android application which extends the

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.