Results 1 to 4 of 4
  1. #1
    JulianD_M is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Question Help with ZipFile and ZipEntry!

    I Have a ZipFile called "a.zip" inside this file i have txt called "test.txt" I Need to read this file, and save it in a File variable.

    Any help would be so great :D

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,033
    Rep Power
    6

    Default Re: Help with ZipFile and ZipEntry!

    So I presume you want to write a Java program to process zip files? What have you tried so far? What problems are you having?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    JulianD_M is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default Re: Help with ZipFile and ZipEntry!

    So far, I know how to read the names inside the zip, but i don't have any idea about how to storage an especific file inside the zip (a.txt), in a File variable.

    try{
    FileInputStream ArchSelec = new FileInputStream(Dir);
    ZipInputStream ZipS=new ZipInputStream(ArchSelec);
    ZipFile zf = new ZipFile(Dir);
    ZipEntry ze = new ZipEntry(Dir);

    while((ze=ZipS.getNextEntry())!=null){
    System.out.println(ze.getName());
    System.out.println(ze.getSize());
    }
    ZipS.close();


    }catch(Exception A){

    JOptionPane.showMessageDialog(this, "Wrong File");
    }

  4. #4
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,033
    Rep Power
    6

    Default Re: Help with ZipFile and ZipEntry!

    You need to read in the file from an InputStream retrieved via ZipFile.getInputStream(). As you read in the contents of the entry,
    you need to write them out using FileOutputStream or equivalent. Check out the tutorials in my signature on doing file I/O.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. How to read multiple ZipEntry using single InputStream?
    By prasannadavid in forum New To Java
    Replies: 5
    Last Post: 09-08-2010, 02:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •