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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:06:06+00:00 2026-06-13T11:06:06+00:00

So I have a input stream from which I read a smaller fixed-size buffer

  • 0

So I have a input stream from which I read a smaller fixed-size buffer which I’m trying to Deflate inside a Runnable class.

randomClass implements Runnable {
    public void run() {
        ...
        byte[] output = new Byte[FIXED];
        Deflater deflater = new Deflater();
        deflater.setInput(uncompressed);
        deflater.setLevel(Deflater.DEFLATED);
        int length = deflater.deflate(output);
        ...
    } 
}

The issue I’m running into is that length is always returning 0 which means I need more input according to the doc? However, I’ve checked that the uncompressed is not null. How can I get the bytes out of the output?

Also I believe I should be calling deflater.finish() only at the last block. Is this correct?

  • 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-13T11:06:07+00:00Added an answer on June 13, 2026 at 11:06 am

    I think compresser.finish(); should be called right after deflater.setInput(uncompressed);. Then proceed with the next steps, it should be fine.

    Same is mentioned in the documentation as below:

     byte[] output = new byte[100];
     Deflater compresser = new Deflater();
     compresser.setInput(input);
     compresser.finish();  //<-- finished is called here
     int compressedDataLength = compresser.deflate(output);
    

    Also, please set the level at the time of initialization e.g.

     Deflater compresser = new Deflater(Deflater.DEFLATED, false); //<-set the level
     byte[] output = new byte[100];
     compresser.setInput(input);
     compresser.finish();  //<-- finished is called here
     int compressedDataLength = compresser.deflate(output);
    

    Hope this helps.

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

Sidebar

Related Questions

I'm trying to figure out how to read from the standard input stream of
I am basically trying to return from a method which reads user input from
I have a set of data inside a database which has been input with
I am reading from an input stream which I am receiving from a server
I have an input stream, and I want to map to output lines. For
I have been testing the performance of reading server socket input stream. I found
So a FILE stream can have both input and output buffers. You can adjust
I'm looking to read from a XML file which is stored within a zip
I have a low level caching mechanism which receives a json array from a
I am looking for a way to branch (tee) the input read from an

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.