Total members 10261 | Gratitudes |It is currently Tue May 22, 2012 5:02 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: get the Contents of a ZIP File in java
PostPosted: Tue Nov 11, 2008 10:55 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Code:
import java.util.*;
import java.util.zip.*;
import java.io.*;

public class ListZipFiles{
  public static void main(String[] args) throws IOException{
    ListZipFiles zf = new ListZipFiles();
  }

  public ListZipFiles() throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter Zip file name: ");
    String filename = in.readLine();
//    File file = new File(filename);
    if(!filename.endsWith(".zip")){
      System.out.println("Invalid file name!");
      System.exit(0);
    }
    else if(!new File(filename).exists()){
      System.out.println("File not exist!");
      System.exit(0);
    }

    try{
      ZipFile zipFile = new ZipFile(filename);
      Enumeration em = zipFile.entries();
      for (Enumeration em1 = zipFile.entries(); em1.hasMoreElements();) {
        System.out.println(em1.nextElement());
      }
    }
    catch(ZipException ze){
      System.out.println(ze.getMessage());
      System.out.println("Zip file may be corrupted.");
      System.exit(0);
    }
  }
}

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 video chat application in java
 Image Insert in Excel File Using POI
 ASP file structure
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 Search records from text file
 Java Programing to communicating port parallel
 Java Chat

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: Google Adsense [Bot] and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team