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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:55:04+00:00 2026-05-26T02:55:04+00:00

private byte[] loadClassData(String className) { ZipInputStream in = null; FileInputStream fis = null; try

  • 0
    private byte[] loadClassData(String className) {
    ZipInputStream in = null;
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(jarPath);
        in = new ZipInputStream(new BufferedInputStream(fis));
        ZipEntry entry;
        while ((entry = in.getNextEntry()) != null) {
            if (entry.getName().contains(".class")) {
                String outFileName = entry.getName()
                        .substring(0, entry.getName().lastIndexOf('.'))
                        .replace('/', '.');
                if (outFileName.equals(className)) {
                    if (entry.getSize() == -1) {
                        Log.e("loadClassData", "can't read the file!");
                        return null;
                    }
                    byte[] classData = new byte[(int) entry.getSize()];
                    in.read(classData);
                    return classData;
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            fis.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}

In debug , I always get the size of “in” is 512 bytes so that I can’t get the rest of my file,and I don’t know why.Does ZipInputStream have size limit?
Thank you!

  • 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-26T02:55:05+00:00Added an answer on May 26, 2026 at 2:55 am
     if (entry.getSize() == -1) {
    

    ZipEntry.getSize() Returns the uncompressed size of the entry data, or -1 if not known.. You need to remove this check.

    I always get the size of “in” is 512 bytes

    How are you checking this? ZipInputStream has no size properties. Whatever you are checking is unrelated.

    This seems to be a good canonical example of ZipInputStream usage.

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

Sidebar

Related Questions

private List<String> subList; private List<List<String>> records = new ArrayList<List<String>>(); for(....){ subList = new ArrayList<String>();
I am using the RSACryptoServiceProvider like this... private byte[] RSAEncrypt(byte[] DataToEncrypt, string ContainerName, bool
Given private int width = 400; private byte [] data = new byte [2];
/// <summary></summary> private Byte[] _ReceiveBytes(Int32 size) { MemoryStream memory = null; SocketAsyncEventArgs args =
I have the following function private byte[] Function(string url) { HttpWebRequest webRequest= (HttpWebRequest)WebRequest.Create(url); webRequest.AddRange(0,
I'm trying to serialize/deserialize string. Using the code: private byte[] StrToBytes(string str) { BinaryFormatter
I found the following code on the web: private byte [] StreamFile(string filename) {
public byte[] transform(ClassLoader loader, String className, Class<?> clazz, ProtectionDomain domain, byte[] bytes) throws IllegalClassFormatException
private string? typeOfContract { get { return (string?)ViewState[typeOfContract]; } set { ViewState[typeOfContract] = value;
private IEnumerable<string> Tables { get { yield return Foo; yield return Bar; } }

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.