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


Java TarArchiveOutputStream.setLongFileMode方法代码示例

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


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

示例1: tarFolder

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
/**
 * Tar a given folder to a file.
 *
 * @param folder the original folder to tar
 * @param destinationFile the destination file
 * @param waitingHandler a waiting handler used to cancel the process (can
 * be null)
 * @throws FileNotFoundException exception thrown whenever a file is not
 * found
 * @throws ArchiveException exception thrown whenever an error occurred
 * while taring
 * @throws IOException exception thrown whenever an error occurred while
 * reading/writing files
 */
public static void tarFolder(File folder, File destinationFile, WaitingHandler waitingHandler) throws FileNotFoundException, ArchiveException, IOException {
    FileOutputStream fos = new FileOutputStream(destinationFile);
    try {
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        try {
            TarArchiveOutputStream tarOutput = (TarArchiveOutputStream) new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.TAR, bos);
            try {
                tarOutput.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
                File matchFolder = folder;
                addFolderContent(tarOutput, matchFolder, waitingHandler);
            } finally {
                tarOutput.close();
            }
        } finally {
            bos.close();
        }
    } finally {
        fos.close();
    }
}
 
开发者ID:compomics,项目名称:compomics-utilities,代码行数:35,代码来源:TarUtils.java

示例2: TarOutputService

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
@CreatesObligation
public TarOutputService(
        final FsModel model,
        final Sink sink,
        final TarDriver driver)
throws IOException {
    Objects.requireNonNull(model);
    this.driver = Objects.requireNonNull(driver);
    final OutputStream out = sink.stream();
    try {
        final TarArchiveOutputStream
                taos = this.taos = new TarArchiveOutputStream(out,
                    DEFAULT_BLKSIZE, DEFAULT_RCDSIZE, driver.getEncoding());
        taos.setAddPaxHeadersForNonAsciiNames(driver.getAddPaxHeaderForNonAsciiNames());
        taos.setLongFileMode(driver.getLongFileMode());
        taos.setBigNumberMode(driver.getBigNumberMode());
    } catch (final Throwable ex) {
        try {
            out.close();
        } catch (final Throwable ex2) {
            ex.addSuppressed(ex2);
        }
        throw ex;
    }
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:26,代码来源:TarOutputService.java

示例3: addFileToTarGz

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
/**
 * Creates a tar entry for the path specified with a name built from the base
 * passed in and the file/directory name. If the path is a directory, a
 * recursive call is made such that the full directory is added to the tar.
 *
 * @param tOut
 *          The tar file's output stream
 * @param path
 *          The filesystem path of the file/directory being added
 * @param base
 *          The base prefix to for the name of the tar file entry
 *
 * @throws IOException
 *           If anything goes wrong
 */
private static void addFileToTarGz(TarArchiveOutputStream tOut, String path, String base) throws IOException {
  File f = new File(path);
  String entryName = base + f.getName();
  TarArchiveEntry tarEntry = new TarArchiveEntry(f, entryName);

  tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
  tOut.putArchiveEntry(tarEntry);

  if (f.isFile()) {
    IOUtils.copy(new FileInputStream(f), tOut);

    tOut.closeArchiveEntry();
  } else {
    tOut.closeArchiveEntry();

    File[] children = f.listFiles();

    if (children != null) {
      for (File child : children) {
        addFileToTarGz(tOut, child.getAbsolutePath(), entryName + "/");
      }
    }
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:40,代码来源:TarGzCompressionUtils.java

示例4: addFileToTarGz

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
/**
 * Creates a tar entry for the path specified with a name built from the base
 * passed in and the file/directory name. If the path is a directory, a
 * recursive call is made such that the full directory is added to the tar.
 * @param tOut
 *          The tar file's output stream
 * @param path
 *          The filesystem path of the file/directory being added
 * @param base
 *          The base prefix to for the name of the tar file entry
 * @throws IOException
 *           If anything goes wrong
 */
private static void addFileToTarGz(TarArchiveOutputStream tOut, String path, String base)
    throws IOException {
  File f = new File(path);
  String entryName = base + f.getName();
  TarArchiveEntry tarEntry = new TarArchiveEntry(f, entryName);

  tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
  tOut.putArchiveEntry(tarEntry);

  if (f.isFile()) {
    IOUtils.copy(new FileInputStream(f), tOut);

    tOut.closeArchiveEntry();
  } else {
    tOut.closeArchiveEntry();

    File[] children = f.listFiles();

    if (children != null) {
      for (File child : children) {
        addFileToTarGz(tOut, child.getAbsolutePath(), entryName + "/");
      }
    }
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:39,代码来源:TarGzCompressionUtils.java

示例5: apply

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
private File apply(String archiveFilename, File outputDir) throws ArchiveException, IOException {
  File archive = new File(outputDir, (archiveFilename + ".tar"));
  FileOutputStream tarOutput = new FileOutputStream(archive);

  TarArchiveOutputStream tarBall = (TarArchiveOutputStream)new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.TAR, tarOutput);
  tarBall.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
  try {
    addFilesToTar(tarBall, new File(workingDir, directory));
  } finally {
    tarBall.close();
  }

  File outputFile = new File(outputDir, (archiveFilename));
  compress(archive, outputFile);
  FileUtils.deleteQuietly(archive);
  return outputFile;
}
 
开发者ID:heroku,项目名称:heroku-maven-plugin,代码行数:18,代码来源:Tar.java

示例6: compressFiles

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
public static void compressFiles(Collection<File> files, File output)
    throws IOException {
    // Create the output stream for the output file
    FileOutputStream fos = new FileOutputStream(output);
    // Wrap the output file stream in streams that will tar and gzip everything
    TarArchiveOutputStream taos = new TarArchiveOutputStream(
        new GZIPOutputStream(new BufferedOutputStream(fos)));
    // TAR has an 8 gig file limit by default, this gets around that
    taos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR); // to get past the 8 gig limit
    // TAR originally didn't support long file names, so enable the support for it
    taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);

    // Get to putting all the files in the compressed output file
    for (File f : files) {
        addFilesToCompression(taos, f, ".");
    }

    // Close everything up
    taos.close();
    fos.close();
}
 
开发者ID:shopzilla,项目名称:hadoop-in-a-box,代码行数:22,代码来源:ClusterStateManager.java

示例7: createContainer

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
@Override
protected TarArchiveOutputStream createContainer(ServletOutputStream sout, String comment) {
    LOGGER.info("Constructing tar archive: {}", comment);
    TarArchiveOutputStream tout = new TarArchiveOutputStream(sout, "UTF8");
    tout.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
    tout.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
    return tout;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:9,代码来源:MCRTarServlet.java

示例8: constructNewStream

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
private void constructNewStream(File outputDir) throws IOException {
  String archiveName = new SimpleDateFormat("yyyyMMddhhmm'.tar.gz'")
      .format(new Date());
  LOG.info("Creating a new gzip archive: " + archiveName);
  fileOutput = new FileOutputStream(
      new File(outputDir + File.separator + archiveName));
  bufOutput = new BufferedOutputStream(fileOutput);
  gzipOutput = new GzipCompressorOutputStream(bufOutput);
  tarOutput = new TarArchiveOutputStream(gzipOutput);
  tarOutput.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:12,代码来源:CommonCrawlDataDumper.java

示例9: marshal

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
@Override
public void marshal(final Exchange exchange, final Object graph, final OutputStream stream) throws Exception {
    String filename = exchange.getIn().getHeader(FILE_NAME, String.class);
    Long filelength = exchange.getIn().getHeader(FILE_LENGTH, Long.class);
    if (filename == null) {
        // generate the file name as the camel file component would do
        filename = StringHelper.sanitize(exchange.getIn().getMessageId());
    } else {
        filename = Paths.get(filename).getFileName().toString(); // remove any path elements
    }

    TarArchiveOutputStream tos = new TarArchiveOutputStream(stream);
    tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
    tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);

    InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, graph);
    if (filelength == null) {
        filelength = (long) is.available();
    }

    TarArchiveEntry entry = new TarArchiveEntry(filename);
    entry.setSize(filelength);
    tos.putArchiveEntry(entry);

    try {
        IOHelper.copy(is, tos);
    } finally {
        tos.closeArchiveEntry();
        IOHelper.close(is, tos);
    }

    String newFilename = filename + ".tar";
    exchange.getOut().setHeader(FILE_NAME, newFilename);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:35,代码来源:TarFileDataFormat.java

示例10: addFileToTar

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
private void addFileToTar(File source, File file, String fileName) throws IOException, ArchiveException {
    File tmpTar = File.createTempFile(source.getName(), null, parentDir);
    tmpTar.delete();
    if (!source.renameTo(tmpTar)) {
        throw new IOException("Could not make temp file (" + source.getName() + ")");
    }

    FileInputStream fis = new FileInputStream(tmpTar);
    TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, fis);
    TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source));
    tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
    tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);

    InputStream in = new FileInputStream(file);

    // copy the existing entries    
    ArchiveEntry nextEntry;
    while ((nextEntry = tin.getNextEntry()) != null) {
        tos.putArchiveEntry(nextEntry);
        IOUtils.copy(tin, tos);
        tos.closeArchiveEntry();
    }

    // Add the new entry
    TarArchiveEntry entry = new TarArchiveEntry(fileName == null ? file.getName() : fileName);
    entry.setSize(file.length());
    tos.putArchiveEntry(entry);
    IOUtils.copy(in, tos);
    tos.closeArchiveEntry();

    IOHelper.close(fis, in, tin, tos);
    LOG.trace("Deleting temporary file: {}", tmpTar);
    FileUtil.deleteFile(tmpTar);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:35,代码来源:TarAggregationStrategy.java

示例11: addEntryToTar

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
private void addEntryToTar(File source, String entryName, byte[] buffer, int length) throws IOException, ArchiveException {
    File tmpTar = File.createTempFile(source.getName(), null, parentDir);
    tmpTar.delete();
    if (!source.renameTo(tmpTar)) {
        throw new IOException("Cannot create temp file: " + source.getName());
    }

    FileInputStream fis = new FileInputStream(tmpTar);
    TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, fis);
    TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source));
    tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
    tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);

    // copy the existing entries    
    ArchiveEntry nextEntry;
    while ((nextEntry = tin.getNextEntry()) != null) {
        tos.putArchiveEntry(nextEntry);
        IOUtils.copy(tin, tos);
        tos.closeArchiveEntry();
    }

    // Create new entry
    TarArchiveEntry entry = new TarArchiveEntry(entryName);
    entry.setSize(length);
    tos.putArchiveEntry(entry);
    tos.write(buffer, 0, length);
    tos.closeArchiveEntry();

    IOHelper.close(fis, tin, tos);
    LOG.trace("Deleting temporary file: {}", tmpTar);
    FileUtil.deleteFile(tmpTar);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:TarAggregationStrategy.java

示例12: cacheLibrary

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
private void cacheLibrary (String language, String name)
		throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
		FTPListParseException
{
	File libdir = new File(cachedir, language + "/" + name);
	WorkerMain.getLogger().info("Caching Library " + name + " (" + language + ") to " + libdir.getAbsolutePath());
	libdir.mkdirs();
	DatastoreFtpClient.retrieveLibrary(name, language, libdir);
	File libtar = new File(cachedir, language + "/" + name + ".tar.bz2");
	TarArchiveOutputStream tar = new TarArchiveOutputStream(new BZip2CompressorOutputStream(new FileOutputStream(libtar)));
	tar.setBigNumberMode(BIGNUMBER_POSIX);
	tar.setLongFileMode(LONGFILE_POSIX);
	addToTar(libdir, tar, "");
	tar.close();
}
 
开发者ID:Turnierserver,项目名称:Turnierserver,代码行数:16,代码来源:LibraryCache.java

示例13: writeClassPath

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
/**
 * @param pathElements
 * @param entry
 * @param archiveOutputStream
 * @throws IOException
 */
private static void writeClassPath(LinkedList<String> pathElements, File entry, TarArchiveOutputStream archiveOutputStream) throws IOException {
    if (entry.isFile()) {
        archiveOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
        archiveOutputStream.putArchiveEntry(new TarArchiveEntry(entry, getPath(pathElements) + SEPARATOR + entry.getName()));
        copy(entry, archiveOutputStream);
        archiveOutputStream.closeArchiveEntry();
    } else {
        pathElements.addLast(entry.getName());
        for (File child : entry.listFiles()) {
            writeClassPath(pathElements, child, archiveOutputStream);
        }
        pathElements.removeLast();
    }
}
 
开发者ID:asebak,项目名称:embeddedlinux-jvmdebugger-intellij,代码行数:21,代码来源:FileUtilities.java

示例14: tarFolderContent

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
/**
 * Tar the content of a given folder to a file.
 *
 * @param folder the original folder to tar
 * @param destinationFile the destination file
 * @param exceptionsPaths a list of paths to files or folders which should be excluded from taring
 * @param waitingHandler a waiting handler used to cancel the process (can
 * be null)
 * @throws FileNotFoundException exception thrown whenever a file is not
 * found
 * @throws ArchiveException exception thrown whenever an error occurred
 * while taring
 * @throws IOException exception thrown whenever an error occurred while
 * reading/writing files
 */
public static void tarFolderContent(File folder, File destinationFile, HashSet<String> exceptionsPaths, WaitingHandler waitingHandler) throws FileNotFoundException, ArchiveException, IOException {
    FileOutputStream fos = new FileOutputStream(destinationFile);
    try {
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        try {
            TarArchiveOutputStream tarOutput = (TarArchiveOutputStream) new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.TAR, bos);
            try {
                tarOutput.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
                for (File file : folder.listFiles()) {
                    String path = file.getAbsolutePath();
                    if (!exceptionsPaths.contains(path)) {
                        if (file.isDirectory()) {
                            addFolderContent(tarOutput, file, waitingHandler);
                        } else {
                            addFile(tarOutput, file, waitingHandler);
                        }
                    }
                }
            } finally {
                tarOutput.close();
            }
        } finally {
            bos.close();
        }
    } finally {
        fos.close();
    }
}
 
开发者ID:compomics,项目名称:compomics-utilities,代码行数:44,代码来源:TarUtils.java

示例15: makeArchiveOutputStream

import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; //导入方法依赖的package包/类
@Override
public ArchiveOutputStream makeArchiveOutputStream(
        OutputStream stream) throws IOException, ArchiveException {
    TarArchiveOutputStream taos = new TarArchiveOutputStream(stream);
    taos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
    taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
    return taos;
}
 
开发者ID:turbolocust,项目名称:GZipper,代码行数:9,代码来源:Tarball.java


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