Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Unzipping a File

                         

Lets learn how to unzip a file using java.

The java.util.zip.ZipEntry class is used to represent a zip file entry. The java.util.zip.ZipEntry class implements java.util.zip.ZipConstants interface. Here we passing the zipped file name to be unzipped using command line argument .To unzip a file first create an object of byte stream then take the array of any size as per your convenience (Here we are taking 1000 as the size of byte array ) then create a text file. First convert the zipped file into the byte array and then write the zipped file into it, To flush and close the file call  flush() and close() respectively.
If it throws any exception then catch it in try/catch block. We are printing the whole exception using printStrackTrace() method.


Here is the code of the program :

import java.io.*;
import java.util.zip.*;
public class UnzipExample
  {
public static void main(String a[])
    {
    try
    {
     BufferedOutputStream out = null;
    ZipInputStream  in = new ZipInputStream
(
new BufferedInputStream(new FileInputStream(a[0])));
    ZipEntry entry;
    while((entry = in.getNextEntry()) != null)
       {
       int count;
       byte data[] new byte[1000];
       out = new BufferedOutputStream(new 
FileOutputStream
("out.txt"),1000);
       while ((count = in.read(data,0,1000)) != -1)
             {
              out.write(data,0,count);
             }
       out.flush();
       out.close();
       }
       }catch(Exception e)
      {
               e.printStackTrace();
           }
     }     
   }

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
jsp export to pdf
how to use unique cons
JButton with image
jsp to microsoft sql
Hibernate API
Murachั??ะ??ั??à
find a replace bytes i
TCP buffer
date validation in jav
writing data to file
The JDBC(tm) Universal
ANTretrieve data from
JSP and Ajax for datab
string to integer
date validation in Jav
Creating a DSN for MyS
login session
Photoshop Basic Shapes
global variable in j
notes applet
Math.random() example
SIMPLE JAVA SOURSE COD
Java code for video pl
standard deviation arr
calculator square root
Servlet Example To Dis
Photoshop Refrozen Eff
Vector
get method of from in
insert data to text fi
image upload
program to validate us
rational robot tool in
customise css in jsp
Math.random()
vector class
ascii
Call Cookies from Serv
struts.jar download
how to take two diment
decimal to ANSI
class connect database
Photoshop Drawing Drag
Scrum
selecting option value
spring dao
show calender page
give me some java pro
validate radio button
calculate perimeter tr
Jigloo
html2pdf
count row in resultset
tattoo efectes
Thread Sleep Method
export database data i
Date Examples java
The eXo platform
linked list and GUI
toInt()
primitive data types
abstract class and abs
jsp login by insertin
jdbcrealm
jQuery To Hide the Div
line break in javascri
div tag
projections
ajax
retrieve image url fro
JSON rest
what is basic stack in
infix to pasfix into s
my clips
jdbc mysql connection
Photoshop Drawing Awes
apache derby embedded
two dimensional array
J2se Tutorial
jquery using .net 2.0
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.