Load zip file and scan zip file : Zip Jar Tar « File Input Output « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. Email
14. Event
15. File Input Output
16. Game
17. Generics
18. Hibernate
19. I18N
20. J2EE
21. J2ME
22. JDK 6
23. JSP
24. JSTL
25. Language Basics
26. Network Protocol
27. PDF RTF
28. Reflection
29. Regular Expressions
30. Scripting
31. Security
32. Servlets
33. Spring
34. Swing Components
35. Swing JFC
36. SWT JFace Eclipse
37. Threads
38. Tiny Application
39. Velocity
40. Web Services SOA
41. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » File Input Output » Zip Jar TarScreenshots 
Load zip file and scan zip file


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class ZipTest {

  public static void scanZipFile(String zipname) {
    try {
      ZipInputStream zin = new ZipInputStream(
          new FileInputStream(zipname));
      ZipEntry entry;
      while ((entry = zin.getNextEntry()) != null) {
        System.out.println(entry.getName());
        zin.closeEntry();
      }
      zin.close();
    catch (IOException e) {
    }
  }

  public static void loadZipFile(String zipname, String name) {
    try {
      ZipInputStream zin = new ZipInputStream(
          new FileInputStream(zipname));
      ZipEntry entry;
      System.out.println("");
      while ((entry = zin.getNextEntry()) != null) {
        if (entry.getName().equals(name)) {
          BufferedReader in = new BufferedReader(
              new InputStreamReader(zin));
          String s;
          while ((s = in.readLine()) != null)
            System.out.println(s + "\n");
        }
        zin.closeEntry();
      }
      zin.close();
    catch (IOException e) {
    }
  }

  public static void main(String[] args) {
    scanZipFile("Your zip file name here");
    loadZipFile("zip file name""file name");

  }
}
           
       
Related examples in the same category
1. Compress a list of files passed in from command line
2. Use Java code to zip a folder
3. List files in a jar file
4. Reading a text file from a jar file without unzipping
5. GZIP compress
6. Uses Zip compression to compress any number of files given on the command line
7. Create a zip file
8. Create Jar file
9. Reading the Contents of a ZIP File
10. Compressing a File
11. UnZip -- print or unzip a JAR or PKZIP file using java.util.zip
12. Read some data from a gzip file
13. Tape Archive Lister: Tar file
w_ww_.ja_va_2___s_.__c___om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.