calling zipping function

calling zipping function

View Answers

April 7, 2009 at 12:14 PM

Hi friend,

Code to help in solving the problem :

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

public class ZipCreateFile{
public static void main(String[] args) throws IOException{
System.out.print("Please enter file name to zip : ");

BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
//String filesToZip = input.readLine();
String filesToZip = "C:\\apache-tomcat-6.0.13\\webapps\\ROOT\\showname.jsp";
File f = new File(filesToZip);
if(!f.exists()){
System.out.println("File not found.");
System.exit(0);
}
System.out.print("Please enter zip file name : ");
String zipFileName = input.readLine();
if (!zipFileName.endsWith(".zip"))
zipFileName = zipFileName + ".zip";
byte[] buffer = new byte[18024];
try{
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
out.setLevel(Deflater.DEFAULT_COMPRESSION);
FileInputStream in = new FileInputStream(filesToZip);
out.putNextEntry(new ZipEntry(filesToZip));
int len;
while ((len = in.read(buffer)) > 0){
out.write(buffer, 0, len);
}
out.closeEntry();
in.close();
out.close();
}
catch (IllegalArgumentException iae){
iae.printStackTrace();
System.exit(0);
}
catch (FileNotFoundException fnfe){
fnfe.printStackTrace();
System.exit(0);
}
catch (IOException ioe){
ioe.printStackTrace();
System.exit(0);
}
}
}

Thanks









Related Tutorials/Questions & Answers:
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.... 
Calling a function
Calling a function  Hi, I have a function xyz() in php code. When a button is clicked it should execute that particular function for that i have... function function xyz() { } but this is not working can u tell me
Advertisements
calling function - JSP-Servlet
calling function  Hai, How to call a java file in jsp file?  Hi friend, Step to be remember for solving the problem : 1.Create a jsp page "test.jsp" Example of Extends Attribute of page
ModuleNotFoundError: No module named 'seaborn-calling-function'
ModuleNotFoundError: No module named 'seaborn-calling-function'  Hi...: No module named 'seaborn-calling-function' How to remove the ModuleNotFoundError: No module named 'seaborn-calling-function' error? Thanks  
Error in calling javascript function from java
Error in calling javascript function from java  I am callin javascriot function from applet and getting error netscape.javascript.JSException: Unexpected error: This method should not be used unless loaded from plugin.jar
From struts calling function to bean - EJB
From struts calling function to bean   I am calling a function from "struts action class" to bean. I am using weblogic 8.1 web server.i am able to call the function from action class,when i restart the server.But when i
calling a javascript function by passing multiple values from applet in web application
calling a javascript function by passing multiple values from applet in web application  Hi all, I have a requirement like this, I have to call a javascript function from JApplet by passing 3 values. I am new to Applets
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
) by calling the function from js?  How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js? I set... the value of 'name1' as "Edit User" when calling the editUser function which
Zipping folder - Java Beginners
Zipping folder  sir, as the part of my academic project, i need... it successfully,,and i tried some recursive method of the same for zipping... solve this.. zipping folder and all of its files and sub folders. thanking
Zipping folder - Java Beginners
Zipping folder  sir, as the part of my academic project, i need... it successfully,,and i tried some recursive method of the same for zipping... solve this.. zipping folder and all of its files and sub folders. thanking
Calling Flex Function From JavaScript
; } .style4 { border-style: solid; border-width: 1px; } Calling Flex Function From JavaScript Sometimes, you may need to call flex function from JavaScript... function using addCallback() function  of ExternalInterface to make the flex
Calling Anonymous JavaScript Function From Flex
: #FFFFCC; } Calling Anonymous JavaScript Function From Flex In flex application, you can call javascript function defined in html file where your flex file is embed. But you can also call an anomymous javascript function
function
function  difference between function overloading and operator overloading
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
Calling Destructor
Calling Destructor  How can i call destructor in java using System.gc() or manually. Please anyone give me a example program   Java is a garbage collected language therefore you cannot predict when (or even
calling setInterval() on onclick event
calling setInterval() on onclick event  Hi all, I am trying...; var xmlHttp; function postRequest...); } function stateChange
calling servlet from jsp
calling servlet from jsp  how to call a servlet from jsp
php calling variables
php calling variables  Can i call a member variable of a class using static method in php
calling a java file in java
calling a java file in java  how to call a another java file in java
Calling from JSP
Calling from JSP  how can we call a class file from JSP   Hi, Do you want to call a servlet or a Java Bean through JSP? Please clarify this. For more information, visit the following link: JSP Tutorials Thanks
Calling Namespace
Calling Namespaced Code From Other File: In the previous tutorial we have seen that how to declare a namespace and how to access the class, function from... class and function from other file. Example:ADS_TO_REPLACE_1 Lib1.php <
Calling servlet from servlet .
Calling servlet from servlet .  How to call a servlet from another... ServletException, IOException { System.out.println("Calling another servlet by using...); System.out.println("Calling another servlet by using SendRedirect
calling method - Java Beginners
calling method   class A{ public void fo(){ class B{ public void fo1(){ System.out.println("fo1 of class B"); } } System.out.println("fo of class A"); } class C{ public void fo2
Calling Constructor in Spring
Calling Constructor in Spring       In the given example you will be learning about a constructor and how to call a constructor in the Spring. Declaring constructor injection
Server calling of .exe file in the client
Server calling of .exe file in the client   I have a requirement with java webapplication. We are using jboss as appserver on Linux machine. How can I call a .exe file from client machine? I want to run .exe from webpage like
Calling awt Frame methods from subclass
Calling awt Frame methods from subclass  Calling awt Frame methods from subclass
calling java beans - JSP-Servlet
calling java beans  Sir, I want to know where to place the java beans java file and class file inside tomcat web server. and how to call them from jsp file.  Hi Friend, Java Bean is placed in classes\form
Calling a jsp page from Servlet
Calling a jsp page from Servlet  How can I do this? Suppose I have jsp page aaa.jsp. From aaa.jsp on form action I have made a call to a servlet xxx.java. In xxx.java I have written code to retrieve data from database through
Calling Action on form load - Struts
Calling Action on form load  Hi all, is it possible to call... this list is coming from the action which i m calling before the page is being... to direct user directly to this page i m calling an action which is preparing a list
isNaN function
isNaN function  What does isNaN function do
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
ModuleNotFoundError: No module named 'sequana-variant-calling'
ModuleNotFoundError: No module named 'sequana-variant-calling'  Hi...: No module named 'sequana-variant-calling' How to remove the ModuleNotFoundError: No module named 'sequana-variant-calling' error? Thanks   
ModuleNotFoundError: No module named 'django-countries-with-calling-codes'
ModuleNotFoundError: No module named 'django-countries-with-calling-codes' ...: ModuleNotFoundError: No module named 'django-countries-with-calling-codes' How to remove the ModuleNotFoundError: No module named 'django-countries-with-calling
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
If function in PHP
If function in PHP  Hi, Provide me the example of If function in PHP. ThanksADS_TO_REPLACE_1   Hi, If function is PHP is used to check... of if() function in PHP:ADS_TO_REPLACE_2 $book="PHP"; if($book=="PHP"){ echo "Book
function method
function method  input Rs. 12000 Discount= 10%, 8% = Rs.(12000-1200) = Rs.(10800-864) = Rs. 9936
function method
function method  input Rs. 12000 Discount= 10%, 8% = Rs.(12000-1200) = Rs.(10800-864) = Rs. 9936
using function
using function   using a function to find the value of v from the foiiowing expression 1v=1u+1*f
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...); } } } } This is my Zipping code and i'll tell you i am having such a time, i give
instead of calling an individual ResultSet.getXXX method for each column.
instead of calling an individual ResultSet.getXXX method for each column.  How do I retrieve a whole row of data at once, instead of calling an individual ResultSet.getXXX method for each column
calling servlet from JS and return response from servlet to JS
page when user clicks on a button i am calling a javascript function(eg myFunc...calling servlet from JS and return response from servlet to JS  hello...) to the function myFunc and the myFunc will load that file(url) on the same webpage using
disable function
disable function  Sir, I have called a java script function when one radio button is checked i want to disable this function when another radio button is checked ,both radio buttons are of same group Please help Thanks in advance
PHP Function
values to the calling portion. One function can be called number of times... manageable, robust. A general format of the function in PHP is as follows:ADS_TO_REPLACE_1 function <function name> (<list of parameters>
calling from iphone through programitically in iphone
calling from iphone through programitically in iphone  calling from iphone through programitically in iphone please help me my senario is if i click send sms button message should deliver to xyz person and that xyz person make
unoin function
unoin function  how to define a union function in java?(ex:a=a U b) how to write tha java code?give ex.   Java Union Function You have learnt union, intersection etc in Sets. Here the given code finds the union of two
calling webservices that return complexTypes in android using ksoap2
calling webservices that return complexTypes in android using ksoap2   Can anyone direct me to a site or show me an example ,on how to call a webservice which returns a complexType as the result, in an android app
Append Function in Java
Append Function in Java  What is the use of append function in java? How to use the append function to append a string to a buffer string. Thanks... through calling the toString() on the StringBufferobject. Use StringBuffer is very

Ads