List of usage examples for org.apache.commons.compress.compressors.xz XZCompressorOutputStream XZCompressorOutputStream
public XZCompressorOutputStream(final OutputStream outputStream) throws IOException
From source file:org.jboss.tools.tycho.sitegenerator.GenerateRepositoryFacadeMojo.java
/** * Add p2 stats to the repository's artifacts.xml (and .jar and .xml.xz) * See http://wiki.eclipse.org/Equinox_p2_download_stats * // ww w . j a v a 2 s .co m * @param theXml * @param theXmlXz * @param transformer * @param source * @throws MojoFailureException * * */ private void alterXzFile(File theXml, File theXmlXz, Transformer transformer, DOMSource source) throws MojoFailureException { try { // JBDS-3929 overwrite the artifacts.xml.xz file too // see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=464614 //getLog().debug("delete " + theXmlXz.toString()); FileUtils.forceDelete(theXmlXz); //getLog().debug("create " + theXml.toString() + " from transformed XML"); FileOutputStream outStreamXml = new FileOutputStream(theXml); StreamResult resultXml = new StreamResult(outStreamXml); transformer.transform(source, resultXml); outStreamXml.close(); //getLog().debug("stream " + theXml.toString() + " to " + theXmlXz.toString()); BufferedInputStream in = new BufferedInputStream(new FileInputStream(theXml)); XZCompressorOutputStream out = new XZCompressorOutputStream(new FileOutputStream(theXmlXz)); final byte[] buffer = new byte[1024]; int n = 0; while (-1 != (n = in.read(buffer))) { out.write(buffer, 0, n); } out.close(); in.close(); //getLog().debug("new " + theXmlXz.toString() + " written; remove " + theXml.toString()); FileUtils.forceDelete(theXml); } catch (IOException | TransformerException ex) { getLog().error(ex); throw new MojoFailureException("Error while compressing " + theXml.toString(), ex); } }
From source file:org.renjin.primitives.io.connections.XzFileConnection.java
@Override protected OutputStream doOpenForOutput() throws IOException { return new XZCompressorOutputStream(super.doOpenForOutput()); }
From source file:org.torproject.collector.index.CreateIndexJson.java
private void writeIndex(IndexNode indexNode) throws IOException { indexJsonFile.getParentFile().mkdirs(); Gson gson = new GsonBuilder().create(); String indexNodeString = gson.toJson(indexNode); Writer[] writers = new Writer[] { new FileWriter(indexJsonFile), new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(indexJsonFile + ".gz"))), new OutputStreamWriter(new XZCompressorOutputStream(new FileOutputStream(indexJsonFile + ".xz"))), new OutputStreamWriter( new BZip2CompressorOutputStream(new FileOutputStream(indexJsonFile + ".bz2"))) }; for (Writer writer : writers) { BufferedWriter bufferedWriter = new BufferedWriter(writer); bufferedWriter.write(indexNodeString); bufferedWriter.close();// ww w.ja v a2 s . c om } }