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");
}

Similar Messages

  • How to display swf Files and have a datagrid with paging for javaFX

    is there any example of javaFX which can display swf files or have a datagrid with paging.
    sorry for my bad english and by the way i am new to javaFX
    any help wil be appreciate

    Please, refrain from posting identical messages in several forums. Thanks.
    And I doubt JavaFX can display SWF files (it is a concurrent technology, after all! :-)), unless using some JNI/JNA technology (via JDIC? a long way...).
    Datagrid: it is expected in next version (hopefully), there are some implementations around (look for CRUDfx, for example).

  • How to rename a file once it is created with util_file utility.

    Hi,
    A flat file is generated with util_file utility, now we want to rename the file using utilities available with Oracle. Can any body give any solution..?, Any package is available...?
    Regards,
    G. Rajakumar.

    Hi Raja
    If you are using Oracle 8i or later version you can easily do it writing a Java stored procedure and calling it,
    in your PL/SQL wrapper function.
    I recently had a similar problem and did it successfully.
    If you need the code along with the wrapper function, I can send it to you on your e-mail.
    Qurashi

  • I have several disks with many comedy routines;I want to select a few from each disk and combine them to one disk for my personal use.How?

    I have several disks with many comedy routines;I want to select a few from each disk to make one single disk for my personal use.How?

    Copy the routines into a new folder on your hard drive. Then burn the folder to a new blank disc using Disk Utility.

  • I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query parameter to report parameter i need to pass distinct values. How can i resolve this

    I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query
    parameter to report parameter i need to pass distinct values. How can i resolve this

    Hi nancharaiah,
    If I understand correctly, you want to pass distinct values to report parameter. In Reporting Service, there are only three methods for parameter's Available Values:
    None
    Specify values
    Get values from a query
    If we utilize the third option that get values from a dataset query, then the all available values are from the returns of the dataset. So if we want to pass distinct values from a dataset, we need to make the dataset returns distinct values. The following
    sample is for your reference:
    Select distinct field_name  from table_name
    If you have any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How do I combine files that have already been combined

    How do I combine files that have already been combined?

    Hi Oldshep1959
    I didn't get you ...Please Explain your workflow ...

  • HOW DO I FIND FILES THAT HAVE BEEN TRANSFERED FORM MY PC TO MY MAC

    How do i locate files that have been transfered from my PC to my new MacBook Pro

    Depends how they were transferred. If you used Migration Assistant, a new user was created. Look there in your documents folder. If you used Setup Assistant, look in your documents folder.

  • How do I access files that have been recovered (after a Mavericks problem) with the .cca file extension

    How do I access files that have been recovered (after a Mavericks problem) with the .cca file extension

    First, to access documents you must use an app designed for that specific Document type. So Pages will not be able to open PDFs. The Documents app by Readdle can handle PDFs though. In the latter case, you'd open the app, click the menu icon at its top left, and click Open to go to your iCloud Drive. With Pages, if you had files outside the main Pages folder, click + then iCloud and navigate to the file's location.
    Matt

  • How do I compress a string with  java.util.zip - not a file ?

    How do I compress a string with java.util.zip?
    Is possible to compress something else except a file?

    Of course, compression works on bytes, not some higher level constructs like Strings or files.
    You can use the ZipOutputStream or DeflaterOutputStream for compression.
    And the javadoc for Deflater even has a code example of compressing a String.
    Edited by: Kayaman on May 22, 2011 5:04 PM

  • How did my pdf files get converted from 'open with Adobe Reader' to open with Adobe Acobat'?  And if I have a ''free'' Acrobat account why does it not open?  When I do click on the account it ask me to pay $89.99.  I never wanted Acrobat.  How can I get -

    How did my stored files get converted from 'open with Adobe READER' to 'open with Adobe ACROBAT'? How can I get them re-set to open with 'Adobe Reader'?
    Please reply to my e-mail:   [email protected]

    It sounds as if you downloaded Adobe Acrobat Pro. If you did, uninstall it. Then repair Adobe Reader.
    The free Acrobat account has no connection to any of this.

  • On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?

    On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?

    I have find the codec installed on my PC do you see an undesirable one I have highlighted the one that seems strange should I uninstall how can I do this safely
    Daniel
    Codecs audio
    Type
    Nom
    Format
    Binaire
    Version
    ACM
    Codec Microsoft IMA ADPCM
    0011
    ACM
    CODEC A-Law et u-Law Microsoft CCITT G.711
    0007
    ACM
    Codec audio Microsoft GSM 6.10
    0031
    ACM
    Codec Microsoft ADPCM
    0002
    ACM
    Fraunhofer IIS MPEG Layer-3 Codec (decode only)
    0055
    ACM
    Convertisseur PCM Microsoft
    0001
    DMO
    WMAudio Decoder DMO
    0160, 0161, 0162, 0163
    WMADMOD.DLL
    6.1.7601.17514
    DMO
    WMAPro over S/PDIF DMO
    0162
    WMADMOD.DLL
    6.1.7601.17514
    DMO
    WMSpeech Decoder DMO
    000A, 000B
    WMSPDMOD.DLL
    6.1.7601.17514
    DMO
    MP3 Decoder DMO
    0055
    mp3dmod.dll
    6.1.7600.16385
    Codecs vidéo
    Type
    Nom
    Format
    Binaire
    Version
    ICM
    Microsoft RLE
    MRLE
    msrle32.dll
    6.1.7601.17514
    ICM
    Microsoft Vidéo 1
    MSVC
    msvidc32.dll
    6.1.7601.17514
    ICM
    Microsoft YUV
    UYVY
    msyuv.dll
    6.1.7601.17514
    ICM
    Codec Intel IYUV
    IYUV
    iyuv_32.dll
    6.1.7601.17514
    ICM
    Toshiba YUV Codec
    Y411
    tsbyuv.dll
    6.1.7601.17514
    ICM
    Codec Cinepak de Radius
    cvid
    iccvid.dll
    1.10.0.13
    DMO
    Mpeg4s Decoder DMO
    mp4s, MP4S, m4s2, M4S2, MP4V, mp4v, XVID, xvid, DIVX, DX50
    mp4sdecd.dll
    6.1.7600.16385
    DMO
    WMV Screen decoder DMO
    MSS1, MSS2
    wmvsdecd.dll
    6.1.7601.17514
    DMO
    WMVideo Decoder DMO
    WMV1, WMV2, WMV3, WMVA, WVC1, WMVP, WVP2
    wmvdecod.dll
    6.1.7601.18221
    DMO
    Mpeg43 Decoder DMO
    mp43, MP43
    mp43decd.dll
    6.1.7600.16385
    DMO
    Mpeg4 Decoder DMO
    MPG4, mpg4, mp42, MP42
    mpg4decd.dll
    6.1.7600.16385
    De : sarika02 
    Envoyé : 17 juin 2014 19:26
    À : Daniel Cloutier
    Objet :  On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?
    On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?
    created by sarika02 <https://forums.adobe.com/people/sarika02>  in Photoshop Elements - View the full discussion <https://forums.adobe.com/message/6466796#6466796>

  • How to import MXF files to Final Cut Pro with smooth editing

    Summary: Follow this tutorial to learn how to import and edit MXF files in Final Cut Pro by converting MTS to FCP native format.
    If you have a Panasonic P2, Canon XF or Sony XDCAM series camcorder,
    you may be familiar with Material eXchange Format (MXF). Though MXF is a
    great video format to record high-definition videos, it is not easy to
    use in that they are not natively supported by most NLE systems like
    Final Cut Pro. In order to import MXF to FCP for editing, the easy workaround is to transcode MXF files to FCP compatible video formats.
    Along with some help from a top MXF Converter, it can be done. To
    help those who wanna edit MXF files in FCP without problems, here I
    share with you a simple guide on how to convert MXF files to edit in
    Final Cut Pro 6/7 or FCP X.
    First of all, downloading the App- Brorsoft MXF Converter for Mac
    Overall, the program is a professional yet easy-to-use MXF Converter
    on Mac (Mavericks included) which can not only convert XF100, Canon
    C300, XF105 and XF305, Panasonic P2 recorded MXF files, but also provide
    simple video editing functions for you. The MXF to FCP Converter not
    only can convert MXF to ProRes for FCP, but also can transcode MXF
    videos for editing in Avid MC, Adobe Premiere Pro, iMovie, FCE, etc.
    Just download it and follow the tutorial below to get the work done.
    Transcoding (P2) MXF files to ProRes for Final Cut Pro 6/7/X
    1. Import MXF files to the converter
    Launch the best MXF to FCP Converter, and then click the “add files” button to browse and import MXF videos from your camcorder or hard drive.
    2. Select FCP editable format
    Click the Format bar, and move mouse cursor to choose “Final Cut Pro > Apple ProRes 422 (*.mov)” as output format.
    Tips:
    a. Settings- click to set video
    resolution(1920×1080/1440×1080/1280×720/720×480), bitrate (from 1Mbps to
    20Mbps), frame rate (24p/30p)
    b. Editor (next to “Add” icon)- click to set deinterlace, trim, crop, add effect, attach subtitles, etc
    3. Start transcoding MXF video to FCP
    Click “Convert” button to start converting MXF files to Apple ProRes
    MOV for FCP 6/7/X under Mac OS. Once the MXF to ProRes 422 conversion
    is done, you can transfer MXF footage into Final Cut Pro (X) for editing
    smoothly on Mac with ease.
    Source:How to import MXF files to Final Cut Pro with smooth editing
    [quote] jacknjchn.tumblr.com/post/76914947404/cant-import-mxf-footage-to-fcp-transcoding-mxf-to-fcp [/quote]

    You may refer to this step by step guide on how to convert MXF to Final Cut Pro more supported Apple ProRes or DV at http://www.idealshare.net/imovie-fcp/mxf-final-cut-pro.html
    It also applies to convert MXF to other video or audio format. It even applies to convert other videos like AVCHD, MOD, TOD, AVI, and MPEG etc to FCP format.

  • How do add .mov files in Premiere Elements 11 with Windows 8? I get a generic error message.

    How do add .mov files in Premiere Elements 11 with Windows 8? I get a generic error message.

    Hi Steve,
    Thanks for your quick response. The original movies were taken on a Canon ES970 (1990's). I don't know the resolution but things were not as high tech back then.,.. I used a Roxio software to convert them on my MacBook Air. I didn't realize that I could use Adobe Premiere Elements to do that or I would have. However my old camera did not have a cable to attach it to a computer and the Roxio software came with it.
    I then saved the recordings on an external hard drive. I did not make movies from them using iMovie or edit them in any way. They are simply .MOV files and they can be played on my Mac. Upon realizing how much memory it takes to work on videos, I decided it might be easier to burn DVD's on my husband's  new Dell desktop that came with Windows 8. I downloaded Quicktime as suggested and still the movies can't be added to Premiere.

  • How to create a file under web application root from java program

    how to create a file under web application root from java program like an action class?

    like an action class?Huh? What exactly is your requirement?
    Creating a file is usually done with java.io API. Read the java.io tutorials how to play with files.

  • The selected signed file could not be authenticated. The file might have been tampered with or an error might have occured during download. Please verify the MD5 hash value against the Cisco Systems web site

    I am trying to load any 9.0.3 firmware on my UCM 5.0.4.2000-1 server. Every newer firmware I load throws the following error. I have verified the MD5 is correct and also downloaded the file several times with the same result. I can load the same firmware file on another UCM server and it loads fine. Any ideas?
    Thanks in advance!
    Error Message:
    The selected signed file could not be authenticated. The file might have been  tampered with or an error might have occured during download. Please verify the  MD5 hash value against the Cisco Systems web site:  9b:b6:31:09:18:15:e7:c0:97:9f:e6:fe:9a:19:94:99
    Firmware File: cmterm-7970_7971-sccp.9-0-3.cop.sgn
    UCM version: 5.0.4.2000-1

    Thanks for your reply. We have a lab environment where I maintain  UCM 5.0, 5.1, 6.0, 6.1, 7.0, 7.1 and 8.0 servers each running the latest released firmware for our QA testing team. I have downloaded and installed the latest device packages but find that if I try to install any firmware newer then 8.3.1 on either 5.0.4 or 6.0 i start getting MD5 hash authentication errors. It looks like 9.0.3 firmware should work on UCM 5.0 and 6.0 so I am lost as to why I can't seem to update any firmware for any model phone if it is newer then version 8.3.1 on either 5.0 or 6.0. while 5.1 and 6.1 work without issues. Maybe it is just a bug. I mostly wanted to see if anyone else has experienced this or if it is just me.

Maybe you are looking for

  • What are the best dimensions to allow for iPad 3 Retina for full-page landscape images?

    What are the best dimensions to allow for iPad 3 Retina for full-page landscape images? I read an article and cannot find it that said something about trying to make it 2million pixels and JPG to keep it small, but what exactly should the dimensions

  • How to put Company Logo in a SAP R/3 Login Screen

    Hi, 1)How can we put our own text in the login screen? 2) how do we put the company logo in the post login R/3 screen? Regards, Shobhit

  • MacBook Pro (2011) won't display 2560x1440 native resolution on external monitor

    I have the new MacBook Pro 15inch with 2.2Ghz quad core and an external NEC PA271W Monitor with a 2560x1440 native resoultion. I have them plugged together via the dual-link DVI-D cable but the MacBook pro will only recognize 1920x1080 as the max res

  • Binary Data to PDF and Word Doc

    All, We have requirement to open a PDF or DOC in a new window from a BAPI output structure. The field returned from the BAPI is a binary field. Following is the code that is implemented for this scenario. for(int i=0;i<wdcontext.nodeOutput().nodePtx_

  • Solaris - Windows JNI Issues

    *** Setting the scene *** I am trying to write a library called GuidGetPid which will have only 1 method to return the current pid. The header file generated by javah only has the following declaration in it: * Class:     GuidGenerator * Method:    g