List of usage examples for org.apache.commons.compress.archivers.tar TarArchiveEntry TarArchiveEntry
public TarArchiveEntry(byte[] headerBuf)
From source file:edu.jhu.hlt.acute.archivers.tar.TarArchiver.java
@Override public void addEntry(Archivable arch) throws IOException { final String fn = arch.getFileName(); TarArchiveEntry entry = new TarArchiveEntry(fn); byte[] cbytes = arch.getBytes(); entry.setSize(cbytes.length);//from w ww . j a va 2s. c om this.tos.putArchiveEntry(entry); try (ByteArrayInputStream bis = new ByteArrayInputStream(cbytes)) { IOUtils.copy(bis, tos); tos.closeArchiveEntry(); } }
From source file:com.pinterest.deployservice.common.TarUtils.java
static void addInputStreamToTar(TarArchiveOutputStream taos, InputStream is, String path, long size, int mode) throws Exception { TarArchiveEntry entry = new TarArchiveEntry(path); entry.setSize(size);//from w w w . j a va2 s. c o m entry.setMode(mode); try { taos.putArchiveEntry(entry); IOUtils.copy(is, taos); } finally { taos.closeArchiveEntry(); Closeables.closeQuietly(is); } }
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();/* www. j a v a 2s.c o m*/ outputStream.closeArchiveEntry(); return chksum; }
From source file:edu.jhu.hlt.concrete.serialization.TarCompactCommunicationSerializer.java
@Override public void toTar(Collection<Communication> commColl, Path outPath) throws ConcreteException, IOException { try (OutputStream os = Files.newOutputStream(outPath); BufferedOutputStream bos = new BufferedOutputStream(os); TarArchiveOutputStream tos = new TarArchiveOutputStream(bos);) { for (Communication c : commColl) { TarArchiveEntry entry = new TarArchiveEntry(c.getId() + ".concrete"); byte[] cbytes = this.toBytes(c); entry.setSize(cbytes.length); tos.putArchiveEntry(entry);/*from w w w . ja v a 2s .c om*/ try (ByteArrayInputStream bis = new ByteArrayInputStream(cbytes)) { IOUtils.copy(bis, tos); tos.closeArchiveEntry(); } } } catch (IOException e) { throw new ConcreteException(e); } }
From source file:msec.org.TarUtil.java
private static void archiveDir(File dir, TarArchiveOutputStream taos, String basePath) throws Exception { File[] files = dir.listFiles(); if (files.length < 1) { TarArchiveEntry entry = new TarArchiveEntry(basePath + dir.getName() + File.separator); taos.putArchiveEntry(entry);/*from ww w . ja v a 2 s . com*/ taos.closeArchiveEntry(); } for (File file : files) { // archive(file, taos, basePath + dir.getName() + File.separator); } }
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);/* ww w . ja v a 2 s .co m*/ tos.putArchiveEntry(entry); tos.write(content); tos.closeArchiveEntry(); }
From source file:br.com.thiaguten.archive.TarArchive.java
@Override protected ArchiveEntry createArchiveEntry(String path, long size, byte[] content) { TarArchiveEntry tarEntry = new TarArchiveEntry(path); tarEntry.setSize(size);//w ww .j av a 2 s . c o m return tarEntry; }
From source file:edu.jhu.hlt.concrete.serialization.TarGzCompactCommunicationSerializer.java
@Override public void toTarGz(Collection<Communication> commColl, Path outPath) throws ConcreteException { try (OutputStream os = Files.newOutputStream(outPath); BufferedOutputStream bos = new BufferedOutputStream(os); GzipCompressorOutputStream gzos = new GzipCompressorOutputStream(bos); TarArchiveOutputStream tos = new TarArchiveOutputStream(gzos);) { for (Communication c : commColl) { TarArchiveEntry entry = new TarArchiveEntry(c.getId() + ".concrete"); byte[] cbytes = this.toBytes(c); entry.setSize(cbytes.length); tos.putArchiveEntry(entry);/*from ww w . java 2 s . com*/ try (ByteArrayInputStream bis = new ByteArrayInputStream(cbytes)) { IOUtils.copy(bis, tos); tos.closeArchiveEntry(); } } } catch (IOException e) { throw new ConcreteException(e); } }
From source file:br.com.thiaguten.archive.GzipArchive.java
@Override protected ArchiveEntry createArchiveEntry(String path, long size, byte[] content) { TarArchiveEntry targzEntry = new TarArchiveEntry(path); targzEntry.setSize(size);/*from w ww . jav a2 s . com*/ return targzEntry; }
From source file:ezbake.deployer.utilities.VersionHelper.java
public static ArtifactDataEntry buildVersionFile(String version) { return new ArtifactDataEntry(new TarArchiveEntry(VERSION_FILE), version.getBytes(Charsets.UTF_8)); }