Don't like ads? PRO users don't see any ads ;-)
Guest

UnzipMe.java

By: NoSalt on Apr 12th, 2012  |  syntax: Java 5  |  size: 0.83 KB  |  hits: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.io.FileInputStream;
  2. import java.io.IOException;
  3. import java.util.zip.ZipInputStream;
  4. import java.io.FileNotFoundException;
  5. import java.util.zip.ZipEntry;
  6.  
  7. public class UnzipMe{
  8.         public static void main(String[] args){
  9.                 FileInputStream fis = null;
  10.                 ZipEntry ze = null;
  11.                 if(args.length != 0){
  12.                         try{
  13.                                 fis = new FileInputStream(args[0]);
  14.                                 ZipInputStream zis = new ZipInputStream(fis);
  15.                                
  16.                                 try{
  17.                                         while((ze = zis.getNextEntry()) != null){
  18.                                                 if(!ze.isDirectory()){
  19.                                                         System.out.println(ze.getName());
  20.                                                 }
  21.                                         }
  22.                                 } catch(IOException ioe){
  23.                                         System.out.println("Something hinkey happened ...");
  24.                                 }
  25.                         } catch(FileNotFoundException fnfe){
  26.                                 System.out.println("Please input a valid ZIP file.");
  27.                         }
  28.                 } else{
  29.                         System.out.println("Please supply a file name.");
  30.                 }
  31.         }
  32. }