Home Discussion Discuss: Create zip file in Java

  • Simplified code for zip file in javaNishanth Thomas December 1, 2011 at 11:52 AM

    import java.io.*; import java.util.zip.*; public class ZipCreateExample{ /** * @param args the command line arguments * @throws FileNotFoundException */ public static void main(String[] args) throws Exception { // input file FileInputStream in = new FileInputStream("F:/Documents and Settings/nishanth1125/Desktop/ZipCreateExample.java");; // out put file ZipOutputStream out = new ZipOutputStream(new FileOutputStream("F:/Documents and Settings/nishanth1125/Desktop/tmp.zip")); // name of file out.putNextEntry(new ZipEntry("zippedjava.java")); byte[] b = new byte[1024]; int count; while ((count = in.read(b)) > 0) { System.out.println(); // write file in zip out.write(b, 0, count); } out.close(); in.close(); } }

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
Java Technology Tutorials

Java file zip
Java file zip In this section, you will learn how to create a zip file... the zip file. Now to create a zip file, we have used the package java..util.zip...., you can create a zip file of any file or a list of files 

JSP Servlet Questions

convert a file .doc to .zip
language="java" %> <HTml> <HEAD><TITLE>Display file upload form...convert a file .doc to .zip  hiii, I uploaded a file with extension .doc now i required with .zip   Hi Friend, Try the following code 

Java-Tutorials

Creating a ZIP file in Java
Creating a ZIP file in Java       Zip File: Zip file format is the popular method... it. For create a zip file from other type of file, following program gives you 

Java-Tutorials

Create zip file in Java
Create zip file in Java     .... You will also learn how to create a zip file from any file through the java... applications. This program shows you how to zip any file through your java 

Java-Tutorials

Unzip a ZIP File
the zip file. ZipEntry: This is the class of java.util.zip.*; package of Java... Unzip a ZIP File       How to unzip (extract) a zip file? How to retrieve elements from 

Java-Tutorials

How to extract zip file in java.
How to extract zip file in java. In this Example, we will discuss how to extract a ZIP file. We will use ZipInputStream class for creating input stream.... The ZipInputStream class will create a input stream and read entry from given Zip file 

General

Create zip file in Java
 

Java Tips and Examples

Zip File Using Java
; This example shows how to create a zip file in java. In other words, we..., WinZip etc. It is also possible to zip and unzip the files from your Java applications. This example shows how we zip a file through a java program 

Java-Tutorials

Listing Contents of a ZIP File
of a zip file through the java code. Following program helps you for the appropriate... Listing Contents of a ZIP File     ... list of elements present in the zip file format. Program Result: This program 

Programming Tutorials

How to make a zip file in java
Description: In this example we will discuss about how to create zip file from... zip file. Code: import java.io.*; import java.util.zip....;} } Output: When you compile and run this program it will create the zip 

Java Beginners

How to create a zip file and how to compare zip size with normal text file
How to create a zip file and how to compare zip size with normal text file  Hi, how are you?I hope you are fine.I want program like how to create zip.../ZipCreateExample.shtml but when i verified the size of zip and normal file,normal file is showing 

Programming Tutorials

Show all the entries of zip file.
Show all the entries of zip file. In this tutorial, We will  discuss how to show all the entries of a zip file.  The ZipFile   class is used...; returns enumeration of zip file entries. The getName() method 

Core Java

Java Zip Package
Java Zip Package      ... and writing the standard and compressed files or archives in the ZIP and GZIP file formats. Basically, ZIP file forms for the JAR file format, so it is easier 

JDK 6 Tutorials

Changes in Jar and Zip
in the file you get the different result. ZIP File Names - Java SE 6... value in the jar file's manifest. There are some changes in ZIP File also: Number of open ZIP files - Prior to Java SE 6, we faced the limitation 

Programming Tutorials

How to generate hash code of Zip file.
C:\>java ZipHashCode Name of Zip file : bharat.txt...How to generate hash code of Zip file. In this tutorial, we will see how to generate hash code of zip file entries. The ZipFile   class is used to read 

JSP Servlet Questions

sending a zip file to servlet
sending a zip file to servlet  I have created a .zip file in a servlet on the local system(no static ip). The .zip file contains xml files. I have to send it to another servlet which is in a server(has a static ip). I have done 

Java Beginners

schedule zip
schedule zip  Java Code to automatically get and zip only .txt files from folders for every 5 days and also to send the zip files to database tables 

Programming Tutorials

Java zip package - Learn how to use java zip package.
Java zip package In this section we will learn about java.util.zip package of java library. We will also learn how to use the zip API to create and read the zip and gzip files within java program. The zip format is very easy method 

PHP Tutorial

Read a zip file.
in reading a zip file. First select a file to be opened. Name that file into zip file and direct the zipread command to read it through while loop. The zip_entry..., it will executed and file will be closed.  <?php $zipname = zip_open(" 

Java Beginners

How to convert multiple files in java to .zip format
How to convert multiple files in java to .zip format  i receive...(); } out.close(); fout.close(); System.out.println("Zip File is created...); } i want to convert the data from inputStream into Zip Stream and so 

Java Beginners

convert zip file to byte array
convert zip file to byte array  Hi,How to convert zip file to byte array,can you please provide program?? Thanks, Ramanuja 

HTML Questions

How to zip a file using javascrip?
How to zip a file using javascrip?  hi.. can anyone tell me How to zip a file using javascrip 

PHP Tutorial

Create a new zip file in ZipArchive.
Creating a new Zip file in ZipArchive For creating zip file, use zipArchive () class. Create a new zip file in ZipArchive. Use the conditional statement... zip file. <?php $newzip = new ZipArchive; $create = $zip->open(&rsquo 

Java Beginners

Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.
Java Util Zip. Zip files/folders inside a folder, without zipping the original... srcFile, ZipOutputStream zip) throws Exception { File folder = new File... TEMP and zip into a file named Final.jar located in the folder Final. Now 

WebSevices Questions

zip file upload in php - WebSevices
zip file upload in php  This is not a normal upload. we know the code for normal upload. i need the zip file upload code in php. how to upload zipfile using php? and how to unzip using php? please i dont 

Mobile Applications Questions

Read file zip in J2ME - MobileApplications
Read file zip in J2ME  I would like to read file.zip in J2ME,I don't know how to extract it. Please help me 

Java Beginners

Issue in Converting .zip file to .jar file?
Issue in Converting .zip file to .jar file?  I have a folder called "printpdf.jar". I have changed the .jar to .zip and did some customizations. After which i had "zipped" it again and made as ".jar". Now the final file 

Development process Questions

find zip file length lessthen 5MB
find zip file length lessthen 5MB  import java.io.BufferedReader...(); } else{ System.out.println("zip file...; } } System.out.println("Zip File 

JSP Servlet Questions

password protected zip file creation exmpale coded neaded - JSP-Servlet
password protected zip file creation exmpale coded neaded  am able to create a zip file and able to read the file but password protection need please help 

Java Server Faces Questions

How to upload zip file from android to server programmatically?????
How to upload zip file from android to server programmatically?????  hi , I want to upload zip file from android phone sdcard to server programmatically. So any one do this task in past so please share your experience with me 

DMCA.com