Need help to zip the files? ? ? ?

hello friends
i am unable to zip the files in my directory by using this program
import java.io.*;
import java.util.zip.*;
public class Zip {
static final int BUFFER = 2048;
public static void main (String argv[]) {
try {
BufferedInputStream origin = null;
FileOutputStream dest = new
FileOutputStream("c:\\zip\\myfigs.zip");
ZipOutputStream out = new ZipOutputStream(new
BufferedOutputStream(dest));
//out.setMethod(ZipOutputStream.DEFLATED);
byte data[] = new byte[BUFFER];
// 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);
FileInputStream fi = new
FileInputStream(files[i]);
origin = new
BufferedInputStream(fi, BUFFER);
ZipEntry entry = new ZipEntry(files[i]);
out.putNextEntry(entry);
int count;
while((count = origin.read(data, 0,
BUFFER)) != -1) {
out.write(data, 0, count);
origin.close();
out.close();
} catch(Exception e) {
e.printStackTrace();
but it is working fine for compress the files in the current directory
but
File f = new File("C:\\ramu");
it shows the error like this
C:\j2sdk1.4.2_09\bin>javac Zip.java
C:\j2sdk1.4.2_09\bin>java Zip
Adding: okh.txt
java.io.FileNotFoundException: C:\ramu (Access is denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at Zip.main(Zip.java:21)
can any body help to rectify this problem

Don't cross-post!
http://forum.java.sun.com/thread.jspa?threadID=5184841&tstart=0
And use code tags already.
The referenced thread already has advice for you (and no, we will not do it for you, you've already been given an example of how to do it, it is up to you to at least attempt it).

Similar Messages

  • I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    You mean an image such as a scanned document?
    If that is the case, the file doesn't contain any text for Reader Out Loud to read. In order to fix that, you would need an application such as Adobe Acrobat that does Optical Character Recognition to convert the images to actual text.
    You can also try to export the file as a Word document or something else using ExportPDF which I believe offers OCR and is cheaper than Acrobat.

  • Need help in laoding flat file data, which has \r at the end of a string

    Hi There,
    Need help in loading flat file data, which has \r at the end of a string.
    I have a flat file with three columns. In the data, at the end of second column it has \r. So because of this the control is going to the beginning of next line. And the rest of the line is loading into the next line.
    Can someone pls help me to remove escape character \r from the data?
    thanks,
    rag

    Have you looked into the sed linux command? here are some details:
    When working with txt files or with the shell in general it is sometimes necessary to replace certain chars in existing files. In that cases sed can come in handy:
    1     sed -i 's/foo/bar/g' FILENAME
    The -i option makes sure that the changes are saved in the new file – in case you are not sure that sed will work as you expect it you should use it without the option but provide an output filename. The s is for search, the foo is the pattern you are searching the file for, bar is the replacement string and the g flag makes sure that all hits on each line are replaced, not just the first one.
    If you have to replace special characters like a dot or a comma, they have to be entered with a backslash to make clear that you mean the chars, not some control command:
    1     sed -i 's/./,/g' *txt
    Sed should be available on every standard installation of any distribution. At lesat on Fedora it is even required by core system parts like udev.
    If this helps, mark as correct or helpful.

  • I need help getting past the installation error "windows cannot fint TEMP file"

    I need help getting past the installation error "windows cannot find TEMP file"

    Seems like some who have tried two devices on the JMICRON IDE port have had trouble. Try without the hard drive and see if you get that error. If that is the case I would try a PATA to SATA converter for your hard drive and connect it to one of the Intel SATA Ports.
    http://www.newegg.com/Product/Product.aspx?Item=N82E16812107112
    http://www.amazon.com/ADDONICS-IDE-SERIAL-CONVERTER-ADIDESA/dp/B000090169
    http://www.compusa.com/products/product_info.asp?product_code=339900#ts
    http://www.xpcgear.com/ide2sata.html
    http://www.ubuyitdirect.com/-p-1045.html?currency=USD
    http://www.satasite.com/sata-ide-converter.htm
    http://www.pcgears.com/default.aspx?oid=187150
     

  • Need a free cold fusion utility that zip the files

    Hi,
    I Need a free cold fusion 5 utility that zip the files or
    folder on my server .
    i already have a cfc file that successfully did this work.
    but i need a script that did this work on cold fuison
    5.

    An
    old
    thread on a zip utility for Coldfusion.
    edit: I have just seen that a zip utility for CF5 might be hard
    to come by. Most people now write code for CFMX. Even the links to
    custom tags have changed.
    Go and search in the
    Exchange.
    You might be lucky. You have to pay for most of the zip utility
    code.

  • I have tried everything I know to retrieve the iPhoto Library app.  I detest this new Photo app, which obviously wasn't designed with photographers in mind.  I desperately need help in retrieving the old app and have not been able to do it so far.

    I have tried everything I know to retrieve the iPhoto Library app.  I detest this new Photo app, which obviously wasn't designed with photographers in mind.  I desperately need help in retrieving the old app and have not been able to do it so far.  I have gone to my app folder and tried to update my iPhoto Library.  I have gone to my trash and brought it over to my desktop and still cannot use it.  Please help!

    Try this fix discovered by User photosb189:
    From Finder, hold down the option key on your keyboard and click on the Go menu at the top of the screen
    Select Library from the drop down menu
    Then navigate to Application Support > iLifeAssetManagement > assets
    Right click on the 'sub' folder and choose Compress
    Drag the resulting zip file to your Desktop (as a backup)
    Go to your System Preferences and choose iCloud
    Turn OFF the iCloud Photos option
    Go back to Library > Application Support and DELETE the iLifeAssetManagement folder
    Now, in System Preferences, turn the iCloud Photos option ON
    iPhoto should now be able to launch. Give it enough time to re-download your Photo Stream content. if you are missing any of your My Photo Stream photos (more than 30 days old), unzip the sub folder on your desktop and drag that into iPhoto.

  • 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]

  • This Adobe muse site file requires a newer version of Adobe Muse. I want to comeback to old version Adobe muse i need help to open my file thanks

    This Adobe muse site file requires a newer version of Adobe Muse. I want to comeback to old version Adobe muse i need help to open my file thanks

    Hi,
    You may need to design the site again in older version OR may be copy and paste in place from new to old except what is new in the latest version.
    Hope that helps!
    Kind Regards,

  • Need to get all the files, well music and video, from my ipod touch 5th gen to my itunes libary.

    Need to get all the files, (well music and video), from my ipod touch 5th gen to my itunes libary. (So basically sync the other way to normal)
    Laptop hard drive broke so had to buy a new one and obviously now need to sort out my itunes.
    Did try downloading all my purchased stuff onto itunes but it has missed some things off, and there are some files I did not purchase from itunes so need a way of getting them back on there.
    Sure this question has been asked a million times but can't find anything to help me on here so thought I'd ask.
    -Did have a look at going onto the start menu and opening the hidden items thing but couldn't see any reference to ipod or device on it so wasn't sure how to do it that way.
    -On itunes under my device when its connected, the section about manually restoring and backing up, would that help me? Because that says it will manually back up my ipod to my computer then could restore that back up, obviously I don't want to accidnetally get rid of everything on my ipod so didn't want to try that just in case without checking.
    (And yes I have disabled auto sync to device when conncected!)
    Can anyone help me please? Sorry if i've overcomplicated this!
    Thanks:)
    Chris

    Backing up an iOS device will copy some data to a backup file within iTunes, but this excludes all media.  You can also transfer iTunes Store purchases from the iDevice to iTunes but, without using a third-party tool, nothing else.  As long as you do not sync the iPod with your new library, the media that's on it will remain ... for as long as it keeps functioning, is not lost, stolen, eaten by the dog, ...
    You may also have an option to recover your previous library from your old laptop; as long as its hard drive isn't fried, a computer repair store or technician may be able to extract the drive, mount it in an external enclosure, and copy your data to another PC.  Whatever you choose, there is no real alternative to having all your media on your computer, managed by iTunes, and regularly backed up to another device/location.

  • I need help with a backup file that was deleted and now undeleted from my hard drive

    Last month (May 6, 2011), I was updating my iPod Touch 4G with the new software that came out. I always make a backup of my iPod's data before I update it. While my iPod was updating I left my iPod and computer alone and was doing things around the house with my mom. And when I was done I went in my room to see if it was done and my computer decides that it was going to freeze and crash on me (with my iPod plugged in and stuck on the updating or verifying software mode.) I managed to get my iPod back to working condition again but losing everything on my iPod. I formatted my computer hard drive but I managed to get back the backup I lost. I need help on getting the backup into iTunes so I can get my data back. I am not Jailbroken and I plan not to Jailbreak. I however saved the backup file in a folder other than the Mobilesync folder. I am also running on Windows XP. Someone please help me and thank you in advance!

    I was able to backup my iPod and I tried to restore my iPod again and it goes through the process and everything but it restores the temporary data that I had on there. It didn't restore application data or the current photos and videos that I had saved in Camera Roll before this all had happened. It is almost like it goes back to factory settings but I have some photos that were saved on the other backup that I was temporarily running on. The backup that I am looking to restore is the only backup file in the Mobilesync folder as of right now the others are saved somewhere safe for right now. Why doesn't it restore my application data or my Camera Roll pictures and videos that I saved before my computer crashed last month? Can this problem be fixed?

  • Operating system command to zip the file

    Hi Experts,
    I got proxy to file scenario, i can place the text file successfully in reciever side, i want to zip the file in reciever side using operating system command option in reciever Communication Channel.
    Can anyone please give me the operating system command to create the zip file in reciever side.
    Kind Regards,
    Praveen.

    Hi Praveen,
    >>Can anyone please give me the operating system command to create the zip file in reciever side.
    Why OS commands and not the PayloadZipModule?
    If you need OS commands check this blog of Michal /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    Update
    You can try this command too
    cmd /C "jar cMf \\<folderpath>test1.zip \\<folderpath>*.*"
    Regards
    Suraj

  • Tablet Zip the file through the algorithm

    My requirment is that I am to zip the file in xi and send to receiver using Soap Adapter. From Receiver again response will go to sender via XI. At the sender side again I want zipped file. Is it possible...
    Do i need to unzip the file at receiver end to make a request.

    Hi Jaideep,
    Ya its possible. You can use the PayloadZipBean for the same. You can both zip and unzip the file using this bean. Use this blog for the same:
    Working with the PayloadZipBean module of the XI Adapter Framework
    And ya you will have to unzip the content of the file if you are to get back a response from the rceiver.
    Regards,
    Sanjeev.

  • In installation process of Acrobat Professional 7 , its showing that Adobe Pdf printer is not Installed...need help to install the software completely

    In installation process of Acrobat Professional 7 , its showing that Adobe Pdf printer is not Installed...need help to install the software completely

    If it is Win 7 or later, the Adobe PDF printer for AA 7 will not install and AcroTray will not function. You will have to install a PS driver from Adobe or maybe an HP color PS printer driver. Then edit the driver properties and change the name to Adobe PDF and the port to FILE. You will always have to do an extra step in creating PDFs by opening the file that is created in Distiller to get the PDF.
    If you are talking about Win 8, you may not be successful at all. If you got Acrobat and Distiller to install, then there is a chance.

  • Zip the file

    Hi
    Oracle 10g , Sunsolaris 5.9
    I am generating csv file using utl_file option and i need to zip that file using plsql
    I try to use this plsql to do this , but it will not zip the file i compile the procdeure but when i run it didnt
    do any thing , where i did a mistake
    procedure filezip as
    --DECLARE
    src_file BFILE;
    v_content BLOB;
    v_blob_len INTEGER;
    v_file UTL_FILE.file_type;
    v_buffer RAW(32767);
    v_amount BINARY_INTEGER := 32767;
    v_pos INTEGER := 1;
    v_blob BLOB;
    BEGIN
    src_file := BFILENAME('*****','test1.txt');
    DBMS_LOB.fileopen(src_file, dbms_lob.file_readonly);
    v_content := utl_compress.lz_compress('src_file');
    v_blob_len := DBMS_LOB.getlength(v_content);
    v_file := UTL_FILE.fopen('EXPORT_DIR','test1.zip','w');
    WHILE v_pos < v_blob_len
    LOOP
    DBMS_LOB.READ(v_content, v_amount, v_pos, v_buffer);
    UTL_FILE.put_raw(v_file, v_buffer, TRUE);
    v_pos := v_pos + v_amount;
    END LOOP;
    UTL_FILE.fclose(v_file);
    EXCEPTION
    WHEN OTHERS THEN
    IF UTL_FILE.is_open(v_file) THEN
    UTL_FILE.fclose(v_file);
    END IF;
    RAISE;
    END;
    rds

    Generaly you need use Java as Procedure. Read this: [http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:952229840241]

  • Question: Need help with overcoming the following message:  "Nothing was imported.

    Need help with overcoming the following message:  “Nothing was imported.  The file(s) or folder(s) selection to import did not contain any supported file types, or the files are already in this catalogue”.
    The photos being scanned are old film shots.  They have NOT been previously scanned.  I am using Photoshop Elements 9 software.
    QUESTION:  how do I override this STOP and or circumvent the photo comparison option????
    Thanks for the help. Bob K ---  [email protected]

      Are you scanning as jpeg, tiff or some other format?
    Are you using continuous numbering for files names as by definition scanned files have no exif data.
     

Maybe you are looking for