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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:12:17+00:00 2026-06-13T13:12:17+00:00

This is part of a larger assignment that I’ve mostly got done except for

  • 0

This is part of a larger assignment that I’ve mostly got done except for this one part, which is a bit embarrassing because it sounds really simply on paper.

So basically, I’ve got a large amount of compressed data. I’ve been keeping track of the length using a CRC32

CRC32 checksum = new CRC32();
...
//read input into buffer
checksum.update(buff, 0, bytesRead);

So it updates everytime more info is read in. I’ve also kept track of the uncompress length using

uncompressedLength += manage.read(buff);

So it is an int value that has the number of bytes of the original file. This is a little Endian machine.

From what I can tell, what I need is four byte CRC, which I used

public byte[] longToBytes(long x) {
    ByteBuffer buffer = ByteBuffer.allocate(8);
    buffer.putLong(x);
    return buffer.array();
}

byte[] c = longToBytes(checksum.getValue());

BUT this is 8 bytes. CRC32.getValue returns a long. Can I convert it to an int in this case without losing information I need?

And then the ISIZE is supposed to be…the four byte compressed length modulo 2^32. I’ve got the variable uncompresedLength which is an int. I think I just have to convert it to bytes and that’s all?

I’ve been hexdumping the result from gzip and the result from my program and my header and data are right, I’m just missing my trailer.

As for why I’m doing this manually, it’s because of an assignment. Trust me, I’d love to just use GZIPOoutputStream if I could.

  • 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-13T13:12:18+00:00Added an answer on June 13, 2026 at 1:12 pm

    CRC32 has 32 bits… the class returns long because of the super interface.

    uncompressed length should be long, since nowadays files larger than 2G isn’t uncommon.

    so in both cases, you need to convert the lowest 32 bits of a long to 4 bytes.

    static byte[] lower4bytes(long v)
    {
        return new byte[] {
                (byte)(v    ),
                (byte)(v>> 8),
                (byte)(v>>16),
                (byte)(v>>24)
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(this is indirectly a part of a much larger homework assignment) I have something
I have a query which works for every order except one. Here's the part
It's a part of larger code base, which forces -Werror on gcc. This warning
I am getting this error as part of this larger puzzle here . var
This part of an app that I am working on, I have the following
I have this part of script from my GAE application which uses webapp2, which
so this is part of my homework assignment. need some help with it. my
A little background: I've got a library of C code that is part of
I have 2 entities: Faculty and Course which are in a one-to-many relationship, that
So this is a small part of a large assignment I have, I'm just

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.