/** * Creates a LZMA compressor. * * @param outputStream the stream to wrap * @throws IOException on error */ public LZMACompressorOutputStream(final OutputStream outputStream) throws IOException { out = new LZMAOutputStream(outputStream, new LZMA2Options(), -1); }
/** * Creates a new XZ compressor using the default LZMA2 options. * This is equivalent to <code>XZCompressorOutputStream(outputStream, 6)</code>. * @param outputStream the stream to wrap * @throws IOException on error */ public XZCompressorOutputStream(final OutputStream outputStream) throws IOException { out = new XZOutputStream(outputStream, new LZMA2Options()); }
FileInputStream inFile = new FileInputStream("src.tar"); FileOutputStream outfile = new FileOutputStream("src.tar.xz"); LZMA2Options options = new LZMA2Options(); options.setPreset(7); // play with this number: 6 is default but 7 works better for mid sized archives ( > 8mb) XZOutputStream out = new XZOutputStream(outfile, options); byte[] buf = new byte[8192]; int size; while ((size = inFile.read(buf)) != -1) out.write(buf, 0, size); out.finish();
/** * Creates a new XZ compressor using the specified LZMA2 preset level. * <p> * The presets 0-3 are fast presets with medium compression. * The presets 4-6 are fairly slow presets with high compression. * The default preset is 6. * <p> * The presets 7-9 are like the preset 6 but use bigger dictionaries * and have higher compressor and decompressor memory requirements. * Unless the uncompressed size of the file exceeds 8 MiB, * 16 MiB, or 32 MiB, it is waste of memory to use the * presets 7, 8, or 9, respectively. * @param outputStream the stream to wrap * @param preset the preset * @throws IOException on error */ public XZCompressorOutputStream(final OutputStream outputStream, final int preset) throws IOException { out = new XZOutputStream(outputStream, new LZMA2Options(preset)); }
private LZMA2Options getOptions(final Object opts) throws IOException { if (opts instanceof LZMA2Options) { return (LZMA2Options) opts; } final LZMA2Options options = new LZMA2Options(); options.setDictSize(numberOptionOrDefault(opts)); return options; }
private LZMA2Options getOptions(final Object opts) throws IOException { if (opts instanceof LZMA2Options) { return (LZMA2Options) opts; } final LZMA2Options options = new LZMA2Options(); options.setDictSize(numberOptionOrDefault(opts)); return options; }
@Override Object getOptionsFromCoder(final Coder coder, final InputStream in) throws IOException { final byte propsByte = coder.properties[0]; int props = propsByte & 0xFF; int pb = props / (9 * 5); props -= pb * 9 * 5; int lp = props / 9; int lc = props - lp * 9; LZMA2Options opts = new LZMA2Options(); opts.setPb(pb); opts.setLcLp(lc, lp); opts.setDictSize(getDictionarySize(coder)); return opts; }
break; case COMPRESSION_FORMAT_XZ_LZMA2: compressionOut = new XZOutputStream(bufferedOut, new LZMA2Options()); mimeTypeRef = "application/x-xz"; break;
break; case COMPRESSION_FORMAT_XZ_LZMA2: compressionOut = new XZOutputStream(bufferedOut, new LZMA2Options()); mimeTypeRef.set("application/x-xz"); break;
/** * Construct an XZ document target using the selected compression preset * * @param os target File * @param presetLevel LZMA2 Compression preset level * @throws UnsupportedOptionsException if the options selected are not acceptable */ public XZFileDocumentTarget(File os, int presetLevel) throws UnsupportedOptionsException { this(os, new LZMA2Options(presetLevel)); }
/** * Construct an XZ document target * * @param file target File */ public XZFileDocumentTarget(File file) { this(file, new LZMA2Options()); }
/** * Construct an XZ document target * * @param file target File */ public XZFileDocumentTarget(File file) { this(file, new LZMA2Options()); }
/** * @param os output stream to wrap * @param presetLevel LZMA2 Preset Level to use * @throws UnsupportedOptionsException if an unsupported preset level is supplied */ public XZStreamDocumentTarget(OutputStream os, int presetLevel) throws UnsupportedOptionsException { this(os, new LZMA2Options(presetLevel)); }
/** * Creates a LZMA compressor. * * @param outputStream the stream to wrap * @throws IOException on error */ public LZMACompressorOutputStream(final OutputStream outputStream) throws IOException { out = new LZMAOutputStream(outputStream, new LZMA2Options(), -1); }
static public XZOutputStream createXZBufferedOutputStream(OutputStream out) { XZOutputStream zout = null; try { zout = new XZOutputStream(new BufferedOutputStream(out), new LZMA2Options()); } catch (IOException e) {e.printStackTrace();} return zout; }
static public XZOutputStream createXZBufferedOutputStream(OutputStream out, int preset) { XZOutputStream zout = null; try { zout = new XZOutputStream(new BufferedOutputStream(out), new LZMA2Options(preset)); } catch (IOException e) {e.printStackTrace();} return zout; }
public byte[] saveWeightVectorToByteArray() throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(new XZOutputStream(new BufferedOutputStream(bos), new LZMA2Options())); oos.writeObject(w_vector); oos.close(); return bos.toByteArray(); }
public void saveModel(AbstractStatisticalComponent<?,?,?,?,?> component, String modelPath) { ObjectOutputStream out; try { out = new ObjectOutputStream(new XZOutputStream(new BufferedOutputStream(new FileOutputStream(modelPath)), new LZMA2Options())); component.save(out); out.close(); } catch (Exception e) {e.printStackTrace();} }
public byte[] toByteArray() throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(new XZOutputStream(new BufferedOutputStream(bos), new LZMA2Options())); save(oos); oos.close(); return bos.toByteArray(); }
private LZMA2Options getOptions(final Object opts) throws IOException { if (opts instanceof LZMA2Options) { return (LZMA2Options) opts; } final LZMA2Options options = new LZMA2Options(); options.setDictSize(numberOptionOrDefault(opts)); return options; }