当前位置: 首页>>代码示例>>Java>>正文


Java TarArchiveEntry.setSize方法代码示例

本文整理汇总了Java中org.apache.commons.compress.archivers.tar.TarArchiveEntry.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java TarArchiveEntry.setSize方法的具体用法?Java TarArchiveEntry.setSize怎么用?Java TarArchiveEntry.setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.compress.archivers.tar.TarArchiveEntry的用法示例。


在下文中一共展示了TarArchiveEntry.setSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addControlContent

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addControlContent ( final TarArchiveOutputStream out, final String name, final ContentProvider content, final int mode ) throws IOException
{
    if ( content == null || !content.hasContent () )
    {
        return;
    }

    final TarArchiveEntry entry = new TarArchiveEntry ( name );
    if ( mode >= 0 )
    {
        entry.setMode ( mode );
    }

    entry.setUserName ( "root" );
    entry.setGroupName ( "root" );
    entry.setSize ( content.getSize () );
    entry.setModTime ( this.getTimestampProvider ().getModTime () );
    out.putArchiveEntry ( entry );
    try ( InputStream stream = content.createInputStream () )
    {
        ByteStreams.copy ( stream, out );
    }
    out.closeArchiveEntry ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:DebianPackageWriter.java

示例2: addFileToArchive

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * add one file to tar.gz file
 *
 * @param file file to be added to the tar.gz
 */
public boolean addFileToArchive(File file, String dirPrefixForTar) {
  try {
    String filePathInTar = dirPrefixForTar + file.getName();

    TarArchiveEntry entry = new TarArchiveEntry(file, filePathInTar);
    entry.setSize(file.length());
    tarOutputStream.putArchiveEntry(entry);
    IOUtils.copy(new FileInputStream(file), tarOutputStream);
    tarOutputStream.closeArchiveEntry();

    return true;
  } catch (IOException e) {
    LOG.log(Level.SEVERE, "File can not be added: " + file.getName(), e);
    return false;
  }
}
 
开发者ID:DSC-SPIDAL,项目名称:twister2,代码行数:22,代码来源:TarGzipPacker.java

示例3: addToTar

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addToTar (File dir, TarArchiveOutputStream tar, String prefix) throws IOException
{
	for (String file : dir.list())
	{
		File f = new File(dir, file);
		WorkerMain.getLogger().debug(f);
		if (f.isDirectory())
			addToTar(f, tar, prefix + file + "/");
		else
		{
			TarArchiveEntry entry = new TarArchiveEntry(prefix + file);
			entry.setSize(f.length());
			tar.putArchiveEntry(entry);
			FileInputStream in = new FileInputStream(f);
			byte buf[] = new byte[8192];
			int read;
			while ((read = in.read(buf)) > 0)
				tar.write(buf, 0, read);
			in.close();
			tar.closeArchiveEntry();
		}
	}
}
 
开发者ID:Turnierserver,项目名称:Turnierserver,代码行数:24,代码来源:LibraryCache.java

示例4: addControlContent

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addControlContent ( final TarArchiveOutputStream out, final String name, final ContentProvider content, final int mode, final Supplier<Instant> timestampSupplier ) throws IOException
{
    if ( content == null || !content.hasContent () )
    {
        return;
    }

    final TarArchiveEntry entry = new TarArchiveEntry ( name );
    if ( mode >= 0 )
    {
        entry.setMode ( mode );
    }

    entry.setUserName ( "root" );
    entry.setGroupName ( "root" );
    entry.setSize ( content.getSize () );
    entry.setModTime ( timestampSupplier.get ().toEpochMilli () );
    out.putArchiveEntry ( entry );
    try ( InputStream stream = content.createInputStream () )
    {
        IOUtils.copy ( stream, out );
    }
    out.closeArchiveEntry ();
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:25,代码来源:DebianPackageWriter.java

示例5: compressTar

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private static void compressTar(String parent, Resource source,TarArchiveOutputStream tos, int mode) throws IOException {
	if(source.isFile()) {
		//TarEntry entry = (source instanceof FileResource)?new TarEntry((FileResource)source):new TarEntry(parent);
		TarArchiveEntry entry = new TarArchiveEntry(parent);
        
        entry.setName(parent);
        
        // mode
        //100777 TODO ist das so ok?
        if(mode>0)	entry.setMode(mode);
        else if((mode=source.getMode())>0)	entry.setMode(mode);
        
        entry.setSize(source.length());
        entry.setModTime(source.lastModified());
        tos.putArchiveEntry(entry);
        try {
        	IOUtil.copy(source,tos,false);
        } 
        finally {
    		tos.closeArchiveEntry();
        }
    }
    else if(source.isDirectory()) {
        compressTar(parent, source.listResources(),tos,mode);
    }
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:27,代码来源:CompressUtil.java

示例6: createArchiveEntry

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * Use for writing streams - must specify file size in advance as well
 */
public static ArchiveEntry createArchiveEntry(String relativePath, ArchiveType archiveType, long size) {
    switch (archiveType) {
        case ZIP:
            ZipArchiveEntry zipEntry = new ZipArchiveEntry(relativePath);
            zipEntry.setSize(size);
            return zipEntry;
        case TAR:
        case TARGZ:
        case TGZ:
            TarArchiveEntry tarEntry = new TarArchiveEntry(relativePath);
            tarEntry.setSize(size);
            return tarEntry;
    }
    throw new IllegalArgumentException("Unsupported archive type: '" + archiveType + "'");
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:19,代码来源:ArchiveUtils.java

示例7: addArchive

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addArchive(File file, TarArchiveOutputStream aos,
		String basepath) throws Exception {
	if (file.exists()) {
		TarArchiveEntry entry = new TarArchiveEntry(basepath + "/"
				+ file.getName());
		entry.setSize(file.length());
		aos.putArchiveEntry(entry);
		BufferedInputStream bis = new BufferedInputStream(
				new FileInputStream(file));
		int count;
		byte data[] = new byte[1024];
		while ((count = bis.read(data, 0, data.length)) != -1) {
			aos.write(data, 0, count);
		}
		bis.close();
		aos.closeArchiveEntry();
	}
}
 
开发者ID:Petasoft,项目名称:Export,代码行数:19,代码来源:ExpProc.java

示例8: addArchiveEntry

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addArchiveEntry(
    TarArchiveOutputStream tarArchiveOutput,
    Object fileContent,
    String pipelineId,
    String fileName
) throws IOException {
  File pipelineFile = File.createTempFile(pipelineId, fileName);
  FileOutputStream pipelineOutputStream = new FileOutputStream(pipelineFile);
  ObjectMapperFactory.get().writeValue(pipelineOutputStream, fileContent);
  pipelineOutputStream.flush();
  pipelineOutputStream.close();
  TarArchiveEntry archiveEntry = new TarArchiveEntry(
      pipelineFile,
      DATA_PIPELINES_FOLDER + pipelineId + "/" + fileName
  );
  archiveEntry.setSize(pipelineFile.length());
  tarArchiveOutput.putArchiveEntry(archiveEntry);
  IOUtils.copy(new FileInputStream(pipelineFile), tarArchiveOutput);
  tarArchiveOutput.closeArchiveEntry();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:21,代码来源:EdgeExecutableStreamingOutput.java

示例9: addDirToArchive

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * adds a directory to a zip file, recursively
 *
 * @param tos TarArchiveOutputStream
 * @param srcFile File
 */
private void addDirToArchive(TarArchiveOutputStream tos, File srcFile) {
    File[] files = srcFile.listFiles();

    for (File file : files) {
        if (file.isDirectory()) {
            addDirToArchive(tos, file);
            continue;
        }

        try {
            logger.debug("Adding file: " + file.getPath());

            TarArchiveEntry entry = new TarArchiveEntry(file.getPath());
            entry.setName(repository.toURI().relativize(file.toURI()).getPath());
            entry.setSize(file.length());
            tos.putArchiveEntry(entry);
            IOUtils.copy(new FileInputStream(file), tos);
            tos.closeArchiveEntry();

        } catch (IOException ioe) {
            logger.error("can not add to tar file. " + ioe.getMessage());
        }

    }
}
 
开发者ID:da-wen,项目名称:GitBackup,代码行数:32,代码来源:TarArchiver.java

示例10: tar

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
public static void tar(File file, File outputPath) throws IOException {

        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(outputPath));
        try (TarArchiveOutputStream tarArchiveOutputStream = new TarArchiveOutputStream(bufferedOutputStream)) {

            if (file != null && file.exists() && file.isFile()) {
                TarArchiveEntry tarFile = new TarArchiveEntry(file, file.getName());
                tarFile.setSize(file.length());
                tarArchiveOutputStream.putArchiveEntry(tarFile);
                IOUtils.copy(new FileInputStream(file), tarArchiveOutputStream);
                tarArchiveOutputStream.closeArchiveEntry();
                tarArchiveOutputStream.finish();
            } else {
                throw new IllegalArgumentException(
                    String.format("File %s is not a file or does not exists.", file.getAbsolutePath()));
            }
        }
    }
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:19,代码来源:IOUtil.java

示例11: toTarGz

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@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);
      try (ByteArrayInputStream bis = new ByteArrayInputStream(cbytes)) {
        IOUtils.copy(bis, tos);
        tos.closeArchiveEntry();
      }
    }

  } catch (IOException e) {
    throw new ConcreteException(e);
  }
}
 
开发者ID:hltcoe,项目名称:concrete-java,代码行数:22,代码来源:TarGzCompactCommunicationSerializer.java

示例12: toTar

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@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);
      try (ByteArrayInputStream bis = new ByteArrayInputStream(cbytes)) {
        IOUtils.copy(bis, tos);
        tos.closeArchiveEntry();
      }
    }

  } catch (IOException e) {
    throw new ConcreteException(e);
  }
}
 
开发者ID:hltcoe,项目名称:concrete-java,代码行数:21,代码来源:TarCompactCommunicationSerializer.java

示例13: getDefaultEntry

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
protected TarArchiveEntry getDefaultEntry(ArchiveContext context, String name, long size) {
    StringBuilder entryName = new StringBuilder(context.getRequest().getItemName());
    entryName.append("-").append(context.getVersion());
    if ( ! name.startsWith(File.separator) ) {
        entryName.append(File.separator);
    }
    entryName.append(name);

    TarArchiveEntry entry = new TarArchiveEntry(entryName.toString());
    entry.setUserName("root");
    entry.setGroupName("root");
    entry.setMode(0644);
    entry.setSize(size);
    entry.setModTime(new Date(System.currentTimeMillis()-(60*60*24*1000)));
    return entry;
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:17,代码来源:AbstractArchiveBasedConfigItem.java

示例14: addTarEntry

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
default void addTarEntry(String path, byte[] content) throws IOException {
    @SuppressWarnings("resource")
    TarArchiveOutputStream tos = getTarArchiveOutputStream();
    TarArchiveEntry entry = new TarArchiveEntry(path);
    entry.setSize(content.length);
    tos.putArchiveEntry(entry);
    tos.write(content);
    tos.closeArchiveEntry();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:10,代码来源:GeneratorContext.java

示例15: addTarEntry

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addTarEntry(TarArchiveOutputStream tos, String path, byte[] content) throws IOException {
    TarArchiveEntry entry = new TarArchiveEntry(path);
    entry.setSize(content.length);
    tos.putArchiveEntry(entry);
    tos.write(content);
    tos.closeArchiveEntry();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:8,代码来源:DefaultProjectGenerator.java


注:本文中的org.apache.commons.compress.archivers.tar.TarArchiveEntry.setSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。