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

  • Home
  • SEARCH
  • 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 111603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:24:43+00:00 2026-05-11T02:24:43+00:00

I have a problem, which I do not seem to be able to solve…

  • 0

I have a problem, which I do not seem to be able to solve… I do a http download of a file, but the CRC32 of the file on the server and on the client do not match. Also, the file has different size, so obviously I must be doing something wrong… when I download via Firefox, the filesize is ok… so I guess it is somewhere in the client code.

I already found Corrupt file when using Java to download file, but that didn’t help me either…

Here’s the code:

private void downloadJar(String fileName, long crc32Server) throws IOException {   System.out.println('Downloading file '' + fileName + '' from server '' + mServer + ''.');   HttpURLConnection sourceConnection = null;   BufferedInputStream inputStream = null;   BufferedWriter fileWriter = null;   long crc32Client;   try {     URL sourceURL = new URL(fileName);     try {       sourceConnection = (HttpURLConnection)sourceURL.openConnection();     }     catch (MalformedURLException exc) {       throw new RuntimeException('Configured URL caused a MalformedURLException: ', exc);     }     sourceConnection.setRequestProperty('Accept-Encoding', 'zip, jar');     sourceConnection.connect();     inputStream = new BufferedInputStream(sourceConnection.getInputStream());     fileWriter = new BufferedWriter(new FileWriter(targetFolder + File.separator + fileName));     CRC32 crc32 = new CRC32();     for (int singleByte = inputStream.read(); singleByte != -1; singleByte = inputStream.read()) {       fileWriter.write(singleByte);       crc32.update(singleByte);     }     crc32Client = crc32.getValue();   }   finally {     if (inputStream != null) {       inputStream.close();     }     if (fileWriter != null) {       fileWriter.flush();       fileWriter.close();     }     if (sourceConnection != null) {       sourceConnection.disconnect();     }   }   if (crc32Client != crc32Server) {     //      deleteFile(fileName);     throw new IOException('CRC32 did not match for file '' + fileName + '': ' + crc32Client + '!='         + crc32Server);   } } 
  • 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. 2026-05-11T02:24:44+00:00Added an answer on May 11, 2026 at 2:24 am

    You should use a BufferedOutputStream instead of a FileWriter/BufferedWriter. In general, *Streams handle raw binary data, while *Writers handle character data (which is an interpretation of the raw binary data for a given character encoding).

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

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 94k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In order to do this you will need to keep… May 11, 2026 at 6:51 pm
  • Editorial Team
    Editorial Team added an answer I can heartily recommend Strawberry Perl. The Portable version is… May 11, 2026 at 6:51 pm
  • Editorial Team
    Editorial Team added an answer You could try to use pyPdf and this example. for… May 11, 2026 at 6:51 pm

Related Questions

I have a problem, which I do not seem to be able to solve...
I'd like to have a World Clock on my PocketPC. Getting the Local Time
I have a menu in my WPF application with multiple options which act like
I have a Cocoa app send some data along with a SHA1 hash of
I have a page in my application that refreshes some content (a list of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.