Java IO Tutorial - Java ZipFile(String name, Charset charset) Constructor








Syntax

ZipFile(String name, Charset charset) constructor from ZipFile has the following syntax.

public ZipFile(String name,   Charset charset)  throws IOException

Example

In the following code shows how to use ZipFile.ZipFile(String name, Charset charset) constructor.

// w ww.  ja  v  a2s  . c o  m
import java.nio.charset.Charset;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {

  public static void main(String[] args) throws Exception {
    ZipFile zipFile = new ZipFile("testfile.zip",Charset.defaultCharset());

    Enumeration zipEntries = zipFile.entries();

    while (zipEntries.hasMoreElements()) {
      System.out.println(((ZipEntry) zipEntries.nextElement()).getName());
    }
    zipFile.close();
  }
}