Source Code : Load zip file and scan zip file

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

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 + "
");
        }
        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");

  }
}
           
         
    
    
    
    
    
    
    
    
  

Thank with us