List of usage examples for java.util.zip ZipInputStream getNextEntry
public ZipEntry getNextEntry() throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream(args[0]); ZipInputStream zis = new ZipInputStream(fis); ZipEntry ze;//w ww . jav a 2s . c om while ((ze = zis.getNextEntry()) != null) System.out.println( ze.getName() + " [" + ze.getSize() + "] [" + new Date(ze.getTime()).toString() + "]"); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream("C:/MyZip.zip"); ZipInputStream zis = new ZipInputStream(fis); ZipEntry ze;/*from w ww . j av a2 s . com*/ while ((ze = zis.getNextEntry()) != null) { System.out.println(ze.getName()); zis.closeEntry(); } zis.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String inFilename = "infile.zip"; ZipInputStream in = new ZipInputStream(new FileInputStream(inFilename)); ZipEntry entry = in.getNextEntry(); String outFilename = "o"; OutputStream out = new FileOutputStream(outFilename); byte[] buf = new byte[1024]; int len;//from w ww . j av a 2s.co m while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); in.close(); }
From source file:MainClass.java
public static void main(String[] args) throws IOException { for (int i = 0; i < args.length; i++) { FileInputStream fin = new FileInputStream(args[i]); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null;//from ww w . j a va 2 s . c om while ((ze = zin.getNextEntry()) != null) { System.out.println("Unzipping " + ze.getName()); FileOutputStream fout = new FileOutputStream(ze.getName()); for (int c = zin.read(); c != -1; c = zin.read()) { fout.write(c); } zin.closeEntry(); fout.close(); } zin.close(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { ZipInputStream zipinputstream = new ZipInputStream(new FileInputStream("filename")); ZipEntry zipentry = zipinputstream.getNextEntry(); while (zipentry != null) { String entryName = zipentry.getName(); File newFile = new File(entryName); String directory = newFile.getParent(); if (directory == null) { if (newFile.isDirectory()) break; }/*w w w . java 2 s. co m*/ RandomAccessFile rf = new RandomAccessFile(entryName, "r"); String line; if ((line = rf.readLine()) != null) { System.out.println(line); } rf.close(); zipinputstream.closeEntry(); zipentry = zipinputstream.getNextEntry(); } zipinputstream.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String zipname = "data.zip"; FileInputStream fis = new FileInputStream(zipname); ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis)); ZipEntry entry;/* ww w .j ava 2 s . co m*/ while ((entry = zis.getNextEntry()) != null) { System.out.println("Unzipping: " + entry.getName()); int size; byte[] buffer = new byte[2048]; FileOutputStream fos = new FileOutputStream(entry.getName()); BufferedOutputStream bos = new BufferedOutputStream(fos, buffer.length); while ((size = zis.read(buffer, 0, buffer.length)) != -1) { bos.write(buffer, 0, size); } bos.flush(); bos.close(); } zis.close(); fis.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String zipname = "d.zip"; CheckedInputStream checksum = new CheckedInputStream(new FileInputStream(zipname), new Adler32()); ZipInputStream zis = new ZipInputStream(new BufferedInputStream(checksum)); ZipEntry entry;/*from w w w.ja v a2s .c o m*/ while ((entry = zis.getNextEntry()) != null) { System.out.println("Unzipping: " + entry.getName()); int size; byte[] buffer = new byte[2048]; BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(entry.getName()), buffer.length); while ((size = zis.read(buffer, 0, buffer.length)) != -1) { bos.write(buffer, 0, size); } bos.flush(); bos.close(); } zis.close(); System.out.println("Checksum = " + checksum.getChecksum().getValue()); }
From source file:ZipReader.java
public static void main(String[] args) throws Exception { ZipInputStream zis = null; FileInputStream fis = new FileInputStream(args[0]); zis = new ZipInputStream(fis); ZipEntry ze;// w w w .j a v a 2 s. c om while ((ze = zis.getNextEntry()) != null) System.out.println(ze.getName()); }
From source file:ZipReader.java
public static void main(String[] args) throws Exception { ZipInputStream zis = null; FileInputStream fis = new FileInputStream(args[0]); zis = new ZipInputStream(fis); ZipEntry ze;/* ww w.ja va2 s . c o m*/ while ((ze = zis.getNextEntry()) != null) System.out.println( ze.getName() + " [" + ze.getSize() + "] [" + new Date(ze.getTime()).toString() + "]"); }
From source file:Main.java
public static void main(String[] args) throws Exception { String destinationname = "d:\\"; byte[] buf = new byte[1024]; ZipInputStream zipinputstream = null; ZipEntry zipentry;/*from w w w. j a v a 2 s .c om*/ zipinputstream = new ZipInputStream(new FileInputStream("fileName")); zipentry = zipinputstream.getNextEntry(); while (zipentry != null) { String entryName = zipentry.getName(); FileOutputStream fileoutputstream; File newFile = new File(entryName); String directory = newFile.getParent(); if (directory == null) { if (newFile.isDirectory()) break; } fileoutputstream = new FileOutputStream(destinationname + entryName); int n; while ((n = zipinputstream.read(buf, 0, 1024)) > -1) { fileoutputstream.write(buf, 0, n); } fileoutputstream.close(); zipinputstream.closeEntry(); zipentry = zipinputstream.getNextEntry(); } zipinputstream.close(); }