Get Specified Entry From Zip File - Java File Path IO

Java examples for File Path IO:Zip File

Description

Get Specified Entry From Zip File

Demo Code

 
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {

  public static void main(String args[]) {
    try {//from  w  w w  .  j  a  va 2 s  .c om
      ZipFile zipFile = new ZipFile("c:/Folder/WebFiles.zip");

      ZipEntry zipEntry = zipFile.getEntry("css/print.css");

      if (zipEntry != null)
        System.out.println("css/print.css found in Zip file");
      else
        System.out.println("css/print.css not found in Zip file");

      zipFile.close();

    } catch (IOException ioe) {
      System.out.println("Error opening zip file" + ioe);
    }
  }
}

Result


Related Tutorials