Advertisement
NoSalt

UnzipMe.java

Apr 12th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.83 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement