All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.XZEncDemo Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
/*
 * XZEncDemo
 *
 * Author: Lasse Collin 
 *
 * This file has been put into the public domain.
 * You can do whatever you want with this file.
 */

import java.io.*;
import org.tukaani.xz.*;

/**
 * Compresses a single file from standard input to standard ouput into
 * the .xz file format.
 * 

* One optional argument is supported: LZMA2 preset level which is an integer * in the range [0, 9]. The default is 6. */ class XZEncDemo { public static void main(String[] args) throws Exception { LZMA2Options options = new LZMA2Options(); if (args.length >= 1) options.setPreset(Integer.parseInt(args[0])); System.err.println("Encoder memory usage: " + options.getEncoderMemoryUsage() + " KiB"); System.err.println("Decoder memory usage: " + options.getDecoderMemoryUsage() + " KiB"); XZOutputStream out = new XZOutputStream(System.out, options); byte[] buf = new byte[8192]; int size; while ((size = System.in.read(buf)) != -1) out.write(buf, 0, size); out.finish(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy