List of usage examples for org.apache.commons.compress.archivers.tar TarArchiveOutputStream write
public void write(int b) throws IOException
From source file:ezbake.protect.ezca.EzCABootstrap.java
protected static void addTarArchiveEntry(final TarArchiveOutputStream tao, String name, byte[] data) { TarArchiveEntry tae = new TarArchiveEntry(name); try {//from ww w .j a va 2 s . c om tae.setSize(data.length); tao.putArchiveEntry(tae); tao.write(data); tao.closeArchiveEntry(); } catch (IOException e) { e.printStackTrace(); } }
From source file:io.syndesis.project.converter.visitor.GeneratorContext.java
default void addTarEntry(String path, byte[] content) throws IOException { TarArchiveOutputStream tos = getTarArchiveOutputStream(); TarArchiveEntry entry = new TarArchiveEntry(path); entry.setSize(content.length);//from ww w .j a v a 2 s .c o m tos.putArchiveEntry(entry); tos.write(content); tos.closeArchiveEntry(); }
From source file:com.ibm.util.merge.storage.TarArchive.java
@Override public String writeFile(String entryName, String content, String userName, String groupName) throws IOException, MergeException { String chksum = super.writeFile(entryName, content, userName, groupName); TarArchiveOutputStream outputStream = (TarArchiveOutputStream) this.getOutputStream(); TarArchiveEntry entry = new TarArchiveEntry(entryName); entry.setSize(content.getBytes().length); entry.setNames(userName, groupName); outputStream.putArchiveEntry(entry); outputStream.write(content.getBytes()); outputStream.flush();//w ww .j av a2 s . c o m outputStream.closeArchiveEntry(); return chksum; }
From source file:com.espringtran.compressor4j.processor.TarProcessor.java
/** * Compress data// w w w . ja v a2 s. c om * * @param fileCompressor * FileCompressor object * @return * @throws Exception */ @Override public byte[] compressData(FileCompressor fileCompressor) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); TarArchiveOutputStream aos = new TarArchiveOutputStream(baos); try { for (BinaryFile binaryFile : fileCompressor.getMapBinaryFile().values()) { TarArchiveEntry entry = new TarArchiveEntry(binaryFile.getDesPath()); entry.setSize(binaryFile.getActualSize()); aos.putArchiveEntry(entry); aos.write(binaryFile.getData()); aos.closeArchiveEntry(); } aos.flush(); aos.finish(); } catch (Exception e) { FileCompressor.LOGGER.error("Error on compress data", e); } finally { aos.close(); baos.close(); } return baos.toByteArray(); }
From source file:com.espringtran.compressor4j.processor.TarBz2Processor.java
/** * Compress data/*from www .j av a 2 s . c om*/ * * @param fileCompressor * FileCompressor object * @return * @throws Exception */ @Override public byte[] compressData(FileCompressor fileCompressor) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BZip2CompressorOutputStream cos = new BZip2CompressorOutputStream(baos); TarArchiveOutputStream aos = new TarArchiveOutputStream(cos); try { for (BinaryFile binaryFile : fileCompressor.getMapBinaryFile().values()) { TarArchiveEntry entry = new TarArchiveEntry(binaryFile.getDesPath()); entry.setSize(binaryFile.getActualSize()); aos.putArchiveEntry(entry); aos.write(binaryFile.getData()); aos.closeArchiveEntry(); } aos.flush(); aos.finish(); } catch (Exception e) { FileCompressor.LOGGER.error("Error on compress data", e); } finally { aos.close(); cos.close(); baos.close(); } return baos.toByteArray(); }
From source file:com.espringtran.compressor4j.processor.TarGzProcessor.java
/** * Compress data/*from w w w. j a v a 2 s . c o m*/ * * @param fileCompressor * FileCompressor object * @return * @throws Exception */ @Override public byte[] compressData(FileCompressor fileCompressor) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GzipCompressorOutputStream cos = new GzipCompressorOutputStream(baos); TarArchiveOutputStream aos = new TarArchiveOutputStream(cos); try { for (BinaryFile binaryFile : fileCompressor.getMapBinaryFile().values()) { TarArchiveEntry entry = new TarArchiveEntry(binaryFile.getDesPath()); entry.setSize(binaryFile.getActualSize()); aos.putArchiveEntry(entry); aos.write(binaryFile.getData()); aos.closeArchiveEntry(); } aos.flush(); aos.finish(); } catch (Exception e) { FileCompressor.LOGGER.error("Error on compress data", e); } finally { aos.close(); cos.close(); baos.close(); } return baos.toByteArray(); }
From source file:com.espringtran.compressor4j.processor.XzProcessor.java
/** * Compress data// w ww . j a va 2 s . c o m * * @param fileCompressor * FileCompressor object * @return * @throws Exception */ @Override public byte[] compressData(FileCompressor fileCompressor) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); XZCompressorOutputStream cos = new XZCompressorOutputStream(baos); TarArchiveOutputStream aos = new TarArchiveOutputStream(cos); try { for (BinaryFile binaryFile : fileCompressor.getMapBinaryFile().values()) { TarArchiveEntry entry = new TarArchiveEntry(binaryFile.getDesPath()); entry.setSize(binaryFile.getActualSize()); aos.putArchiveEntry(entry); aos.write(binaryFile.getData()); aos.closeArchiveEntry(); } aos.flush(); aos.finish(); } catch (Exception e) { FileCompressor.LOGGER.error("Error on compress data", e); } finally { aos.close(); cos.close(); baos.close(); } return baos.toByteArray(); }
From source file:io.syndesis.project.converter.DefaultProjectGenerator.java
private void addTarEntry(TarArchiveOutputStream tos, String path, byte[] content) throws IOException { TarArchiveEntry entry = new TarArchiveEntry(path); entry.setSize(content.length);// w w w .jav a 2 s . com tos.putArchiveEntry(entry); tos.write(content); tos.closeArchiveEntry(); }
From source file:com.puppetlabs.geppetto.forge.v2.api.it.ReleaseTestCreate.java
private void putEntry(TarArchiveOutputStream stream, ModuleName moduleName, Version version, String name, String content) throws IOException { StringBuilder fullName = new StringBuilder(); moduleName.toString(fullName);//from ww w .j ava 2 s . co m fullName.append('-'); version.toString(fullName); fullName.append('/'); fullName.append(name); TarArchiveEntry entry = new TarArchiveEntry(fullName.toString()); byte[] img = content.getBytes(Charsets.UTF_8); entry.setSize(img.length); stream.putArchiveEntry(entry); stream.write(img); stream.closeArchiveEntry(); }
From source file:com.francetelecom.clara.cloud.mvn.consumer.maven.MavenDeployer.java
private File populateTgzArchive(File archive, List<FileRef> fileset) throws IOException { archive.getParentFile().mkdirs();//from ww w. ja v a 2 s .c om CompressorOutputStream zip = new GzipCompressorOutputStream(new FileOutputStream(archive)); TarArchiveOutputStream tar = new TarArchiveOutputStream(zip); for (FileRef fileRef : fileset) { TarArchiveEntry entry = new TarArchiveEntry(new File(fileRef.getRelativeLocation())); byte[] bytes = fileRef.getContent().getBytes(); entry.setSize(bytes.length); tar.putArchiveEntry(entry); tar.write(bytes); tar.closeArchiveEntry(); } tar.close(); return archive; }