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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:04:15+00:00 2026-05-31T00:04:15+00:00

I uploaded a JAR file that was 21 KB in size on my computer

  • 0

I uploaded a JAR file that was 21 KB in size on my computer to a website. I found the direct link to that JAR file and I create an InputStream to that file:

URL url = new URL("addresstofile");
InputStream stream = url.openStream();

It would be expected that the amount of bytes available in the stream would be ~21,000. However, the amount available is 7,048. In an attempt to debug, I saved those 7,048 bytes in a byte array and then I write those bytes to a temporary file with the extension “.jar”

I extract the classes in the JAR file (that is 7 KB; the original is 21 KB). Most of the classes are there except I noticed that nested classes are not present. I am not sure as to why that is – is it just a coincidence that the InputStream just cuts out there, or are there some special exceptions to nested classes?

Why is InputStream acting so oddly?
Thanks!

@Neil: This works! 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-05-31T00:04:16+00:00Added an answer on May 31, 2026 at 12:04 am

    In the modified version of the code you present, the problem is the comparison. Don’t cast ‘b’ to an int before making the comparison with -1. If you do that then if a byte in the stream happens to be 255, you won’t be able to differentiate between this byte and the end of the stream.

    So make the comparison with -1 on the int returned from read(). Then if it’s not -1, cast the value to a byte and put it in the array (or whatever).

    int b;
    while ((b = stream.read()) != -1)
    {
        data[length++] = (byte) b;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After I uploaded my application created using cakephp, I found out that I had
I have jar files that cannot be found on Maven Central repository. I would
I uploaded an audio file to Dropbox and put a link to it in
I've read that JWS checks the jnlp or the jar file on the server
Attempting to move an uploaded file so that it is saved in the directory,
I uploaded my files to my remote server having support for ASP.Net 3.5. Website
We need to send uploaded files from our CMS website to any antivirus product
The file should be uploaded in the background via Ajax or Iframes. I should
I have a Maven project which generates a 413.06 KB jar file. I have
I uploaded a csv file to MySQL DB but for some reason data from

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.