Zipping folder

Zipping folder

View Answers

September 5, 2008 at 4:09 PM

Hi friend,

i am sending zipping code.


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

public class ZipFolderTest {
public static void main (String argv[]) {
try {
BufferedInputStream origin = null;
FileOutputStream fos = new FileOutputStream("/home/vinod/amarexamples/amar.zip");
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(fos));
byte data[] = new byte[2028];
// get a list of files from current directory
File f = new File(".");
String files[] = f.list();

for (int i=0; i<files.length; i++) {
System.out.println("Adding: "+files[i]);
FileInputStream fi = new FileInputStream(files[i]);
origin = new BufferedInputStream(fi);
ZipEntry entry = new ZipEntry(files[i]);
out.putNextEntry(entry);
int count;
while((count = origin.read(data, 0, 2028)) != -1) {
out.write(data, 0, count);
}
origin.close();
}
out.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}

--------------------------------------------------------------------


Read for more information.

http://www.roseindia.net/java/


Thanks.









Related Tutorials/Questions & Answers:
Zipping folder - Java Beginners
solve this.. zipping folder and all of its files and sub folders. thanking...Zipping folder  sir, as the part of my academic project, i need to zip a user selected folder . this folder may contain any number of folder and sub
Zipping folder - Java Beginners
solve this.. zipping folder and all of its files and sub folders. thanking...Zipping folder  sir, as the part of my academic project, i need to zip a user selected folder . this folder may contain any number of folder and sub
Advertisements
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 source folder.   import java.io.File; import... srcFile, ZipOutputStream zip) throws Exception { File folder = new File
calling zipping function - JSP-Servlet
calling zipping function  Hi, Is it possible to zip a jsp file. I wrote a java function for zipping a file.How to call that java file (zipping function ) in JSP ? pls help me Thanks.... 
linux tar folder and subfolders
linux tar folder and subfolders  Hi, I am new to Linux operating... for me for zipping it into a file possible Linux tar file. I just searched and found.... Help me with the command in Linux for archiving folder and subfolders into tar
Folder in Java.
Folder in Java.  I have any problem how to make Folder in java program? Can Anybody help me in this part
create folder
create folder  what code we should write as a web application that it create an empty folder on client's desktop
"The folder name is not valid" netbeans
"The folder name is not valid" netbeans  "The folder name is not valid" while crating a jsp,html or any page in netbeans
create a folder in jsp page
create a folder in jsp page  i want to create a folder in jsp page And it can be delete aslo
copy file from folder to folder - Java Beginners
copy file from folder to folder   my requirement is I need to copy xml files from one folder to another my source file contains the field filename.... Suppose in the source file, file name is goodfile1.xml source folder
struts2 folder struture - Struts
struts2 folder struture  Hi, I just want to know the exact folder structure required for the struts2 application? Its urgent
Java lock file or folder.
Java lock file or folder.  Is it possible to create a desktop application to lock or encrypt file or folder in windows by using java code?? if possible can provide some reference?? because i can't find it... thanks
Last modified date of a folder
Last modified date of a folder  How to get the last modified date of a folder specified by a link in html
URL folder download to local
URL folder download to local  I have a requirement to download all the folders and files inside from a SVN link to my local directory. Can you help how it could be done
java program to copy the contents of one folder to another folder
java program to copy the contents of one folder to another folder  java program to copy the contents of one folder to another folder   Have a look at the following link: Java Copy one folder to another
image save to folder in java
image save to folder in java  Hi, I am working with java. In my application i want to give facility to user to add and change image. I use open... folder and that path stored into database, for furhter retrivation. Please guide me
Zip Folder Using Java
Zipping a Folder       In this example we are going to create a zip folder and all files contained in this folder are zipped by using java. Here we will learn how to compress files
xcode group folder
in Xcode Project Folder. Neelam   Follow the steps.. View -> Smart Groups -> All Files it'll group all the files in Xcode Project Folder. Neelam
How to make a folder icon, make a folder icon, folder icon
How to make a folder icon       The folder is used in the computer, this example will teach you to design technique of the folder.  New File: Take a new file as your folder
how to set folder size in php
how to set folder size in php  hi , i know how to create folder but i dont know how to set size for folder did u know means tell me. thankyour
ModuleNotFoundError: No module named 'folder-rotator'
ModuleNotFoundError: No module named 'folder-rotator'  Hi, My... named 'folder-rotator' How to remove the ModuleNotFoundError: No module named 'folder-rotator' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'folder-syncer'
ModuleNotFoundError: No module named 'folder-syncer'  Hi, My... 'folder-syncer' How to remove the ModuleNotFoundError: No module named 'folder-syncer' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'maxlength-folder'
ModuleNotFoundError: No module named 'maxlength-folder'  Hi, My... named 'maxlength-folder' How to remove the ModuleNotFoundError: No module named 'maxlength-folder' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'sequence-folder'
ModuleNotFoundError: No module named 'sequence-folder'  Hi, My... named 'sequence-folder' How to remove the ModuleNotFoundError: No module named 'sequence-folder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'shadow-folder'
ModuleNotFoundError: No module named 'shadow-folder'  Hi, My... 'shadow-folder' How to remove the ModuleNotFoundError: No module named 'shadow-folder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'smart-folder'
ModuleNotFoundError: No module named 'smart-folder'  Hi, My Python... 'smart-folder' How to remove the ModuleNotFoundError: No module named 'smart-folder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'create-folder'
ModuleNotFoundError: No module named 'create-folder'  Hi, My... 'create-folder' How to remove the ModuleNotFoundError: No module named 'create-folder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cubicweb-folder'
ModuleNotFoundError: No module named 'cubicweb-folder'  Hi, My... named 'cubicweb-folder' How to remove the ModuleNotFoundError: No module named 'cubicweb-folder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'folder-compiler'
ModuleNotFoundError: No module named 'folder-compiler'  Hi, My... named 'folder-compiler' How to remove the ModuleNotFoundError: No module named 'folder-compiler' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'folder-organizer'
ModuleNotFoundError: No module named 'folder-organizer'  Hi, My... named 'folder-organizer' How to remove the ModuleNotFoundError: No module named 'folder-organizer' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'folder-rotator'
ModuleNotFoundError: No module named 'folder-rotator'  Hi, My... named 'folder-rotator' How to remove the ModuleNotFoundError: No module named 'folder-rotator' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'folder-syncer'
ModuleNotFoundError: No module named 'folder-syncer'  Hi, My... 'folder-syncer' How to remove the ModuleNotFoundError: No module named 'folder-syncer' error? Thanks   Hi, In your python
how to download a file from a folder??
how to download a file from a folder??  i can upload any kind of files to a folder, and only the path of the file is saved into the database, now how a client can download the file from my folder. pls provide me the jsp code
Virtualbox shared folder permissions error
Virtualbox shared folder permissions error  Hi, I am running Oracle... as of the guest os. I have shared a folder from my windows computer to the Virtual box vim. The mapping for this folder appears inside the VM but I am not able
search for particular keyword in the folder documents
search for particular keyword in the folder documents  i am having... to particular folder. it is a stand alone application so i have to search particular keyword in the folder having document like in pdf , word or excel
PHP saying folder does not exist
PHP saying folder does not exist  This PHP code is supposed to check if a folder exists based on the value of the URL perimeter ?username= <?php.../Office/user/login.html?error=2"); } ?> But it's saying the folder
Compressing a folder into GZIP format using PHP Windows
Compressing a folder into GZIP format using PHP Windows  How to gzip compress a folder/directory in PHP using windows
how to download the uploaded folder files using jsp
how to download the uploaded folder files using jsp  how to download the uploaded folder files using jsp
how to browse folder and directory in jsp
how to browse folder and directory in jsp  how to browse folder and directory in my jsp page.i have done my coding part for browsing directory but dont know how to get files after that.and also i want to show limited directories
how to backup files and folder with Java
how to backup files and folder with Java  Does anyone know to create a backup with java?. backup files and folders from my computer to an external...:\\Documents and Settings\\bharat\\Desktop\\bipul\\New Folder\\TableExample.java
Full path of image to save it in a folder
in the local context of your project, then you may first create a folder under WEB... of either JDBC or JPA, whichever is known to you. 2. saving the file in a folder...=request.getServletContext().getRealPath("folder url where u want to store your
List Information about folder
List Information about folder       This Example shows you how to show folder information. In this code we have used method of Folder class to retrieve information about
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  How to copy an image from one folder to another folder using jsp
ModuleNotFoundError: No module named 'honeybee-radiance-folder'
ModuleNotFoundError: No module named 'honeybee-radiance-folder'  Hi...: No module named 'honeybee-radiance-folder' How to remove the ModuleNotFoundError: No module named 'honeybee-radiance-folder' error? Thanks  
ModuleNotFoundError: No module named 'honeybee-radiance-folder'
ModuleNotFoundError: No module named 'honeybee-radiance-folder'  Hi...: No module named 'honeybee-radiance-folder' How to remove the ModuleNotFoundError: No module named 'honeybee-radiance-folder' error? Thanks  
ModuleNotFoundError: No module named 'rename-ts-folder'
ModuleNotFoundError: No module named 'rename-ts-folder'  Hi, My... named 'rename-ts-folder' How to remove the ModuleNotFoundError: No module named 'rename-ts-folder' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'zip-folder-sync'
ModuleNotFoundError: No module named 'zip-folder-sync'  Hi, My... named 'zip-folder-sync' How to remove the ModuleNotFoundError: No module named 'zip-folder-sync' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-storages-folder'
ModuleNotFoundError: No module named 'django-storages-folder'  Hi...: No module named 'django-storages-folder' How to remove the ModuleNotFoundError: No module named 'django-storages-folder' error? Thanks   Hi
ModuleNotFoundError: No module named 'folder-compiler-static-website'
ModuleNotFoundError: No module named 'folder-compiler-static-website' ...: No module named 'folder-compiler-static-website' How to remove the ModuleNotFoundError: No module named 'folder-compiler-static-website' error
ModuleNotFoundError: No module named 'honeybee-radiance-folder'
ModuleNotFoundError: No module named 'honeybee-radiance-folder'  Hi...: No module named 'honeybee-radiance-folder' How to remove the ModuleNotFoundError: No module named 'honeybee-radiance-folder' error? Thanks  

Ads