"Java": Compressed into multiple compressed volumes

Source: Internet
Author: User

Java comes with a library that does not support compression into multiple compressed volumes, finds an open source library zip4j, and finds it easier to use so

Package com.jws.common.mail;

Import Java.io.File;

Import Net.lingala.zip4j.core.ZipFile;
Import net.lingala.zip4j.exception.ZipException;
Import Net.lingala.zip4j.model.ZipParameters;

Import Org.apache.log4j.Logger;



public class Mailzip4jservice {
Private Mailzip4jservice () {
}

private Static Class Jiveglobeholder {
private static Mailzip4jservice instance = new Mailzip4jservice ();
}

public static Mailzip4jservice getinstance () {
return jiveglobeholder.instance;
}
Private final Logger log = Logger.getlogger (This.getclass ());

/**
* Zip4j Compressed volume
* @param srcpath Compressed file storage location
* @param FilePath Compressed files
* @param size to split file sizes
* @return
*/
public boolean presssurefile (String srcpath,file filepath,long size) {
try {
ZipFile zipfile = new ZipFile (Srcpath);
Zipparameters parameters = new Zipparameters ();
Zipfile.createzipfile (FilePath, parameters,true, size);
return true;
}catch (Zipexception e) {
Log.error ("Compressed file": Problem with Compression ");
return false;
} catch (Exception e) {
Log.error ("Compressed file": File exception ");
return false;
}

}
}

"Java": Compressed into multiple compressed volumes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.