How to Zip server files(in a directory) and throwing back to client

Can someone tell me how to zip all the files in a particular directory of my web application and throwing back to client to give option for save that zipped file.
i have used the below used function to zip in servlet. But I cann't zip a particular directory of my application in server.
Please help
private void zipDir(String dir2zip, ZipOutputStream zos)
try
//create a new File object based on the directory we
// have to zip File
File fileDir2Zip = new File(dir2zip);
System.out.println("is directory ..."+fileDir2Zip.isDirectory());
//get a listing of the directory content
String[] dirList = fileDir2Zip.list();
for(int i = 0 ; i < dirList.length ; i++)
System.out.println("Dir list ..."+dirList);
byte[] readBuffer = new byte[2156];
int bytesIn = 0;
//loop through dirList, and zip the files
for(int i=0; i<dirList.length; i++)
File f = new File(fileDir2Zip, dirList[i]);
if(f.isDirectory())
//if the File object is a directory, call this
//function again to add its content recursively
String filePath = f.getPath();
zipDir(filePath, zos);
//loop again
continue;
//if we reached here, the File object f was not
//a directory
//create a FileInputStream on top of f
FileInputStream fis = new FileInputStream(f);
//create a new zip entry
ZipEntry anEntry = new ZipEntry(f.getPath());
//place the zip entry in the ZipOutputStream object
zos.putNextEntry(anEntry);
//now write the content of the file to the ZipOutputStream
while((bytesIn = fis.read(readBuffer)) != -1)
zos.write(readBuffer, 0, bytesIn);
System.out.println("Last");
//close the Stream
fis.close();
catch(Exception e)
e.printStackTrace();

Hi
Whatever file exist in directory should execute with out any condition because they delete all files after exection of my process chain. They are using another process chain once a day for deletion of all files in that directory.
So directory always contains fresh files.
Here by using routine in infopackge i am unable to run all files one by one at a time.
As of my knowledge  by using infopackage we can run only one file at a time.
Here my question is , can we run more than one file in single run of infopackage?
or can we have any function module to run the infopackage from externally? so that i can use function module in abap program? any ideas..
Regards
Raju

Similar Messages

  • How to create a file in current directory

    hi,
    I want to create a file in a current directory, But when i written following
    code then it cannot create file, How i will create file in current directory?
    Is there anyone who can help me?what will be the solution of this problem?
    Please give me solution
    String dir=application.getRealPath("/");
         int count;
         String filename="sample.txt";
         out.println(dir+filename);
         FileOutputStream fout=new FileOutputStream(filename);
         PrintStream p;
         p=new PrintStream(fout);
         p.print("1");
         p.close();with regards
    Bina

    hi,
    my problem is that my path is ok...but when i open file in this directory then
    it cannot open a file, is there anyone who can do it? When a user save data in server from remote
    area then what will be path of my code? how i will solve it? please give me
    solution.
    with regards
    bina

  • How to create pdf files in UNIX directory from oracle reports

    I would like to know how to create pdf files in UNIX directory from oracle reports.
    Thanks,

    Please make your question more clear . Also mention the reports version.
    1) If you are runnning reports in Unix, you can give
    .... destype=file desformat=pdf desname=<filename>
    in command line
    Please refer docs below.
    2) If by your question you mean
    "My reports server is running in Windows but I want to ftp my files to Unix after creating it"
    then the answer is that you can use pluggable destination "ftp"
    .... destype=ftp desformat=pdf desname=<ftp url>
    Pluggable destinations download
    http://otn.oracle.com/products/reports/pluginxchange/index.html
    Thanks
    Ratheesh
    [    All Docs     ]
    http://otn.oracle.com/documentation/reports.html
    [     Publishing reports to web  - 10G  ]
    http://download.oracle.com/docs/html/B10314_01/toc.htm (html)
    http://download.oracle.com/docs/pdf/B10314_01.pdf (pdf)
    [   Building reports  - 10G ]
    http://download.oracle.com/docs/pdf/B10602_01.pdf (pdf)
    http://download.oracle.com/docs/html/B10602_01/toc.htm (html)
    [   Forms Reports Integration whitepaper  9i ]
    http://otn.oracle.com/products/forms/pdf/frm9isrw9i.pdf

  • Anyone knows how to delete a file from a directory?????

    hi there
    anyone has any idea on how to delete a file from a directory? delete(String filename)? thank you.

    Hi,
    Check this link.
    Gives you an example code to show how to delete a file.
    http://examples.oreilly.com/jenut/Delete.java
    Hope this helps.
    Roopasri Vittal
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

  • How to zip multi files into one zip file in ABAP

    hi all:
    As you know, ABAP has CL_ABAP_GZIP class to support zip file function. But it only support one file zip. If I want to zip two files into one zip file, how to do it?
    thanks.

    Hi,
    <li>If you know how to zip one file,  to zip two files , you can follow the below steps.
    DATA:g_zipper     TYPE REF TO cl_abap_zip.
    "create our zipper object
    CREATE OBJECT g_zipper.
    "add 1st file to zip
    CALL METHOD g_zipper->add
       EXPORTING
         name    = file_name
         content = content_x.
      "add 2nd file to zip
    CALL METHOD g_zipper->add
       EXPORTING
         name    = file_name
         content = content_y.
    "save zip
    CALL METHOD g_zipper->save
       RECEIVING
         zip = zip.
    Thanks
    Venkat.O

  • How to Zip Excel files using File Adapter?

    Hi,
    We have tried to ZIP the Excel file with  PayloadZipBean in File adapter. But we faced some issue while zipping.
    We have seen some zunk data in excel file after zipping with PayloadZipBean. Someone please help how to zip Excel files in PI with File Adapter.
    Regards,
    Sreeramulu Konjeti.

    Hi Sree,
    If you are facing any issue with PayloadZipBean then you can use java mapping to Zip the files.
    Please find the complete Java mapping code to zipt the file
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50ce0433-4309-2b10-4bb4-d421e78463f7?quicklink=index&overridelayout=true

  • How to duplicate a file in a directory to another directory?

    I am a student just has just learn some basic Java programming...May i know how to duplicate a file in a directory to another directory?
    How to start in doing this?
    Thank You

    I was suggesting to use java to send commands to the system shell so to speak....
    I don't know of a way to do this... under the File class you can delete files, but there is no provision to copy Files so to speak....
    one way would to be to open the file you want to copy with a file reader, and then write it all out to your new file.
    see http://java.sun.com/j2se/1.3/docs/api/java/io/FileReader.html for information of FileReaders

  • How to zip one file i have on disk with java.util.zip

    I don't know how to zip a file. I managed to do new html file, but i don't know how to zip it.
    This is my code:
    PrintWriter pw = new PrintWriter (new FileWriter(export), true);
    Thanks!

    heres a zipper class i wrote which i have butchered a bit to make more generic (its basic and at present only takes one zipentry etc, but very simple and should be easy to extend etc) Just pass it your file in its constructor and then call its zipme method. PS if it can be made better let me know so i can update my class, cheers.
    import java.io.*;
    import java.util.zip.*;
    import java.awt.*;
    class zipper
         public File file;
         public zipper(File f)
              file = new File(f);
         public void zipme()
              try
                   FileInputStream fin = new FileInputStream(file);
                   int a = (int)file.length();
                   byte b[] = new byte[a];
                   fin.read(b);
                   ZipEntry k = new ZipEntry(fin.getName());//represents a single file in a zip archive!
                   File newFile = new File("D:\\AZipFile.zip");
                   ZipOutputStream zi = new ZipOutputStream(new FileOutputStream(newFile));
                   zi.putNextEntry(k);
                   zi.write(b,0,a);
                   zi.close();
                   fin.close();
              catch(FileNotFoundException e)
                   //System.out.println("ERROR File not found");
              catch(IOException ee)
                   //System.out.println("ERROR IO exception in Zipping file");
    }

  • How to ZIP the files and folders/sub folder files using java

    HI All,
    I'm New to this Forum, Could anybody tell me how to zip the files and folders/sub folders using java. For example I have a folder with the name testfolder and side that folder I have some files and some sub folders inside subfolders I have some other files. I need to ZIP the files and folders as they are in same hierarchy.
    Any pointers or help wolud be appritiated.
    Thanks,
    Rajeshbabu V

    [http://www.devx.com/tips/Tip/14049]

  • How to zip a file on mac pro?

    how to zip a file on mac pro?

    Tristan,
    Select multiple items that you want to zip, right click and choose "Compress XX Items."

  • How to download a file from the net and save it into .txt format in a datab

    Can some one show me a tutorial on how to download a file from the net and save it into .txt format in a database?
    Thank you,

    http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html

  • I want read PDF file from SAP directory and create a spool request or print

    Hi all,
    I want read PDF file from SAP directory and create a spool request or print the pdf through SAP. Can any body  help me in this.
    Also please write to me if its possible to open PDF from SAP directory to adobe pdf reader.
    Thanks in advance,
    Sunny

    Hi Sunny,
    Check these links.
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    http://www.erpgenie.com/sap/abap/pdf_creation.htm
    http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
    http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.

    hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.
    i do not have a mac home pc. just a regular pc

    I had the same problem after I gave my old iPad to my parents and tried to install Netflix. This is what you have to do:  Open iTunes on your computer, the one you sync your iPad to. Then go to iTunes Store and search for and download Netflix app. After you download it, if your iPad is set to download new purchases it may start downloading on your iPad. If so, tap and hold to delete the app (because it is trying to install the new version on the iPad) Next step, go to the App Store on your iPad and find Netflix and it should say install since you already purchased it on the computer. Tap to install, and it will say the version is not compatible, tap to download a previous version. Click that and it will install the older version!    One more thing, if and when you sync to your computer again it will say something like " Unable to install Netflix on your iPad" Just click the box to never remind you again, because it's trying to sync the newer Netflix app to your iPad, but it doesn't work so it displays the message. The old app will remain on the ipad. Hope this helps, good luck

  • How to save .pdf file using office word and excel

    Can someone help me how to save .pdf files using office word and excel?  I reinstalled my adobe 7.0 pro in my new pc and before I was able to do it but with my old pc.

    For anything after Office 2003, you have to print to the Adobe PDF printer. If you installed AA 7 on OS newer than XP, you may have to do a workaround to get it to work. With later versions of WORD you can always use the MS plugin for creating PDFs.

  • Thanks.. can u please help me out in one more question. how can i transfer files like pdf, .docx and ppt from my laptop to iPhone 5 ? please its urgent.

    thanks.. can u please help me out in one more question. how can i transfer files like pdf, .docx and ppt from my laptop to iPhone 5 ? please its urgent.

    See your other post
    First, i want to know how can i pair my iPhone 5 with my lenovo laptop?

Maybe you are looking for

  • 64bit and kde Solved thanks to evr

    I installed the 64bit system and then KDE but when I start KDE the screen freezes and I have to reboot, any ideas Last edited by normc (2009-04-06 19:23:01)

  • Problem in creating PDF of Website using Adobe Acrobat Professional 8.

      I am trying to create PDF file of full website using "Create PDF from Web Page..." option, in Adobe Acrobat Professional 8. It is creating PDF but the page alignments/text/images alignments are lost and doesn't look good. Can any one help to create

  • Urgent! Please help with this

    Hi! in the ../server0/log/application.log we see: Error#1#com.sap.lcr.sagent.BuilderDirector#Plain###Data supplier c ircular redirection. Check data supplier bridge targets. At VA we see only SLD data suplier but no "bridge". Please help. Points guar

  • Xml images look pixelated =/

    Hi, I made a site for a friend that uses an xml gallery. If you click the "view portfolio" planet, you will see that the loaded thumbnail images and the full images are pixelly. However, they look fine in the stand-alone swf. I though it might have s

  • Canon 5D Mark III Jpeg problem

    Received my new 5D Mark iii today. Pretty happy so far however I have noticed a strange issue with Apple Aperture when viewing jpegs from the 5d mark iii. I noticed a white line at the top of the frame or the left of the frame on vertical shots. It i