Results 1 to 3 of 3
  1. #1
    beginer@1234 is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default zip a file tp data handler

    Hi,
    ANy one please tell me how can I write a java code which zip a file and directly add it to a data handler .ie with out creation a temporary fie for the zip creation.


    regards,
    shiju

  2. #2
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    441
    Rep Power
    6

    Default

    You dont know,Java has Zip class under java.util for performing Zip operation.
    Mak
    (Living @ Virtual World)

  3. #3
    beginer@1234 is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default

    ..Yeh.. That I know...


    But the solution i need is to directly zip a file to a datahandler. The solution I can embody now zip the file to a temporary location , then adds it to a datahandler.I would like to avoid the temp file to store the new zip , and like to directly zip the file to the datahandler.

    see below..
    public static DataHandler getData(){
    byte[] buf = new byte[18024];
    DataHandler data = null;
    try{
    String filesToZip= "C:\\TestTemp\\Eclipse.txt";
    // String target = "C:\\TestTemp\\outfile.zip";
    String target ="outfile.zip";
    ZipOutputStream out= new ZipOutputStream(new FileOutputStream(data.toString()));
    out.setLevel(Deflater.DEFAULT_COMPRESSION);
    FileInputStream in = new FileInputStream(filesToZip);
    out.putNextEntry(new ZipEntry(filesToZip));
    int len;
    while ((len = in.read(buf)) > 0) {

    out.write(buf, 0, len);
    }
    out.closeEntry();
    in.close();
    out.close();
    //data = new DataHandler(new FileDataSource(target));
    }
    catch(Exception ex){

    System.out.println("Exception");

    }
    return data;
    }



    here you can see the target file. Instead of using it , i need to directly zip the file to the data handler


    Regards,
    Muneer

Similar Threads

  1. CheckedTreeDialog adding Handler/Listener
    By negroscuro in forum SWT / JFace
    Replies: 5
    Last Post: 03-30-2009, 06:30 AM
  2. Redirect Page in SOAP Message Handler
    By bluesheeva in forum Advanced Java
    Replies: 0
    Last Post: 12-28-2008, 12:43 PM
  3. event handler not working properly
    By H3rtaherta in forum Java 2D
    Replies: 3
    Last Post: 11-24-2008, 02:39 AM
  4. Data Sorting in a .data file using java
    By stutiger99 in forum New To Java
    Replies: 2
    Last Post: 10-08-2008, 02:52 AM
  5. Help with Handler
    By baltimore in forum AWT / Swing
    Replies: 1
    Last Post: 08-04-2007, 09:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •