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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:43:41+00:00 2026-05-25T11:43:41+00:00

edit: fixed it with ZipInputStream zin = new ZipInputStream(getAssets().open(totalkeys.zip)); I got an unzipper (

  • 0

edit: fixed it with

ZipInputStream zin = new ZipInputStream(getAssets().open("totalkeys.zip")); 

I got an unzipper ( decompress ) from an example, where it takes a string as a path to a zipped file. But since I have the file in my assets, I somehow need to make to read it from there… well, got this far.

Unfortunately it throws me “ERROR/Decompress(24122): java.lang.ClassCastException: android.content.res.AssetManager$AssetInputStream” Any ideas how to fix it? )

public class dec extends Activity {
/** Called when the activity is first created. */
@Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        Toast.makeText(this, "hello, starting to unZipp!", 15500).show();

        String location = Environment.getExternalStorageDirectory() + "/unzipped/"; 
        /////////////////////////////////////////////////////////////////////

        try  { 

            AssetManager mgr = getBaseContext().getAssets();

            FileInputStream fin = (FileInputStream)mgr.open("totalkeys.zip");
            // throws ERROR/Decompress(24122): java.lang.ClassCastException: android.content.res.AssetManager$AssetInputStream

            //FileInputStream fin = new FileInputStream(_zipFile); /// old one, that wanted a String.
            ZipInputStream zin = new ZipInputStream(fin); 
            ZipEntry ze = null; 
            while ((ze = zin.getNextEntry()) != null) { 
              Log.v("Decompress", "Unzipping " + ze.getName()); 

              if(ze.isDirectory()) { 
                dirChecker(ze.getName()); 
              } else { 
                FileOutputStream fout = new FileOutputStream(location + ze.getName()); 
                for (int c = zin.read(); c != -1; c = zin.read()) { 
                  fout.write(c); 
                } 

                zin.closeEntry(); 
                fout.close(); 
              } 

            } 
            zin.close(); 
          } catch(Exception e) { 
            Log.e("Decompress", "unzip", e); 
          } 

        } 

        private void dirChecker(String dir) { 

          String location = Environment.getExternalStorageDirectory() + "/unzipped/"; 
          File f = new File(location + dir); 

          if(!f.isDirectory()) { 
            f.mkdirs(); 
          } 

        ////////////////////////////////////////////////////

        finish();

}

}

Thanks!

  • 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-25T11:43:41+00:00Added an answer on May 25, 2026 at 11:43 am

    Use your context:

    InputStream is = myContext.getAssets().open("totalkeys.zip");
    

    This returns an input stream which you can read to a buffer.

    // Open the input stream
    InputStream is = mContext.getAssets().open(FILE_NAME);
    
    byte[] buffer = new byte[1024];
    int length;
    while ((length = is.read(buffer))>0){
              // write buffer some where, e.g. to an output stream
              // as 'myOutputStream.write(buffer, 0, length);'
    }
    // Close the stream
    try{
        is.close();
    } catch(IOException e){
        Log.e(this.getLocalClassName().toString(), e.getMessage());
        //this.getLocalClassName().toString() could be replaced with any (string) tag
    }
    

    If you’re working in an activity, you can use this.getAssets() because Activity extends Context. You can also pass an instance of Context to a custom constructor if you’re not working inside an activity and assign this to a member if you need it later.

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

Sidebar

Related Questions

Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls
@edit: fixed everything and decoded the view state and this is what I got
Edit: This is a confirmed bug in jQuery 1.3.1. It is fixed in jQuery
Edit: From another question I provided an answer that has links to a lot
Edit: fixed several syntax and consistency issues to make the code a little more
putchar(263); // edit: fixed typo, was 264 it produced beep (By internally CPU speaker);
Edit: Fixed it by using the same adapter on both spinners. I have two
EDIT: FIXED I CHANGED IT TO this is my code Account Type: <div id=accounttype
EDIT: minor fixes (virtual Print; return mpInstance) following remarks in the answers. I am
Edit: This question was written in 2008, which was like 3 internet ages ago.

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.