Example usage for org.apache.commons.compress.archivers.sevenz SevenZMethod COPY

List of usage examples for org.apache.commons.compress.archivers.sevenz SevenZMethod COPY

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.sevenz SevenZMethod COPY.

Prototype

SevenZMethod COPY

To view the source code for org.apache.commons.compress.archivers.sevenz SevenZMethod COPY.

Click Source Link

Document

no compression at all

Usage

From source file:at.treedb.backup.Export.java

/**
 * Writes an uncompressed binary archive data file.
 * //from  ww  w  . j  a v  a2  s .  co  m
 * @param path
 *            archive path
 * @param data
 *            binary data
 * @param date
 *            file creation date
 * @throws IOException
 */
private void write(String path, byte data[], Date date) throws IOException {
    SevenZArchiveEntry entry = createFileEntry(path, date);
    entry.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.COPY)));
    sevenZOutput.putArchiveEntry(entry);
    System.out.println(path);
    sevenZOutput.write(data);
    sevenZOutput.closeArchiveEntry();
}

From source file:at.treedb.backup.Export.java

/**
 * <p>/*from  w w  w.  j a  v  a 2 s  . c  om*/
 * Tries to find the best compression method for the file data. Actual the
 * code only sets for compressed binary formats (e.g. jpeg) the compression
 * method to COPY.
 * </p>
 *
 * 
 * @param data
 *            binary data
 * @return compression method
 */
public static SevenZMethod findBestCompressionMethod(byte[] data, SevenZMethod compressionMethod) {
    try {
        MimeType mtype = ContentInfo.getContentInfo(data);
        if (mtype != null) {
            switch (mtype) {
            case JPG:
            case PNG:
            case MP4:
            case WEBM:
            case FLV:
                return SevenZMethod.COPY;
            }
        }
    } catch (Exception e) {
        return compressionMethod;
    }
    return compressionMethod;
}