• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TarOutputStream类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.kamranzafar.jtar.TarOutputStream的典型用法代码示例。如果您正苦于以下问题:Java TarOutputStream类的具体用法?Java TarOutputStream怎么用?Java TarOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TarOutputStream类属于org.kamranzafar.jtar包,在下文中一共展示了TarOutputStream类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createLibsTarGz

点赞 3

import org.kamranzafar.jtar.TarOutputStream; //导入依赖的package包/类
public static void createLibsTarGz(List<URL> apiCl, List<URL> containerCL,
                                       Map<String, List<URL>> streamsetsLibsCl,
                                       Map<String, List<URL>> userLibsCL,
                                       File staticWebDir,
                                       File outputFile) throws IOException {
  long now = System.currentTimeMillis() / 1000L;
  FileOutputStream dest = new FileOutputStream(outputFile);
  TarOutputStream out = new TarOutputStream(new BufferedOutputStream(new GZIPOutputStream(dest), 65536));
  // api-lib
  String prefix = ClusterModeConstants.API_LIB;
  out.putNextEntry(new TarEntry(TarHeader.createHeader(prefix, 0L, now, true)));
  addClasspath(prefix, out, apiCl);
  prefix = ClusterModeConstants.CONTAINER_LIB;
  out.putNextEntry(new TarEntry(TarHeader.createHeader(prefix, 0L, now, true)));
  addClasspath(prefix, out, containerCL);
  addLibrary(ClusterModeConstants.STREAMSETS_LIBS, now, out, streamsetsLibsCl);
  addLibrary(ClusterModeConstants.USER_LIBS, now, out, userLibsCL);
  tarFolder(null, staticWebDir.getAbsolutePath(), out);
  out.putNextEntry(new TarEntry(TarHeader.createHeader("libs-common-lib", 0L, now, true)));
  out.flush();
  out.close();
}
 

开发者ID:streamsets,
项目名称:datacollector,
代码行数:23,
代码来源:TarFileCreator.java

示例2: addClasspath

点赞 3

import org.kamranzafar.jtar.TarOutputStream; //导入依赖的package包/类
private static void addClasspath(String prefix, TarOutputStream out, List<URL> urls)
  throws IOException {
  if (urls != null) {
    for (URL url : urls) {
      File file = new File(url.getPath());
      String name = file.getName();
      if (name.endsWith(".jar")) {
        out.putNextEntry(new TarEntry(file, prefix + "/" + file.getName()));
        BufferedInputStream src = new BufferedInputStream(new FileInputStream(file), 65536);
        IOUtils.copy(src, out);
        src.close();
        out.flush();
      }
    }
  }
}
 

开发者ID:streamsets,
项目名称:datacollector,
代码行数:17,
代码来源:TarFileCreator.java

示例3: createTarGz

点赞 2

import org.kamranzafar.jtar.TarOutputStream; //导入依赖的package包/类
public static void createTarGz(File dir,
                               File outputFile) throws IOException {
  Utils.checkState(dir.isDirectory(), Utils.formatL("Path {} is not a directory", dir));
  Utils.checkState(dir.canRead(), Utils.formatL("Directory {} cannot be read", dir));
  FileOutputStream dest = new FileOutputStream(outputFile);
  TarOutputStream out = new TarOutputStream(new BufferedOutputStream(new GZIPOutputStream(dest), 65536));
  File[] files = dir.listFiles();
  Utils.checkState(files != null, Utils.formatL("Directory {} could not be read", dir));
  if(files.length > 0) {
    tarFolder(null, dir.getAbsolutePath(), out);
  }
  out.close();
}
 

开发者ID:streamsets,
项目名称:datacollector,
代码行数:14,
代码来源:TarFileCreator.java

示例4: addLibrary

点赞 2

import org.kamranzafar.jtar.TarOutputStream; //导入依赖的package包/类
private static void addLibrary(final String originalPrefix, long now, TarOutputStream out,
                               Map<String, List<URL>> lib) throws IOException {
  out.putNextEntry(new TarEntry(TarHeader.createHeader(originalPrefix, 0L, now, true)));
  for (Map.Entry<String, List<URL>> entry : lib.entrySet()) {
    String prefix = originalPrefix;
    prefix += "/" + entry.getKey();
    out.putNextEntry(new TarEntry(TarHeader.createHeader(prefix, 0L, now, true)));
    prefix += "/lib";
    out.putNextEntry(new TarEntry(TarHeader.createHeader(prefix, 0L, now, true)));
    addClasspath(prefix, out, entry.getValue());
  }
}
 

开发者ID:streamsets,
项目名称:datacollector,
代码行数:13,
代码来源:TarFileCreator.java

示例5: tarDirectory

点赞 2

import org.kamranzafar.jtar.TarOutputStream; //导入依赖的package包/类
public static void tarDirectory(Path outputFile, Path inputDirectory) throws IOException
{
    System.out.println("Creating archive at: " + outputFile);
    // Output file stream
    FileOutputStream dest = new FileOutputStream(outputFile.toFile());
    final Path outputFileAbsolute = outputFile.normalize().toAbsolutePath();

    final Path inputDirectoryAbsolute = inputDirectory.normalize().toAbsolutePath();
    final int inputPathLength = inputDirectoryAbsolute.toString().length();

    // Create a TarOutputStream
    try (TarOutputStream out = new TarOutputStream(new BufferedOutputStream(dest)))
    {
        Files.walk(inputDirectoryAbsolute).forEach(entry -> {
            if (Files.isDirectory(entry))
                return;

            // Don't try to compress the output.tar file into itself
            if (entry.equals(outputFileAbsolute))
                return;

            try
            {
                String relativeName = entry.toString().substring(inputPathLength + 1);

                out.putNextEntry(new TarEntry(entry.toFile(), relativeName));
                BufferedInputStream origin = new BufferedInputStream(new FileInputStream(entry.toFile()));
                int count;
                byte data[] = new byte[2048];

                while ((count = origin.read(data)) != -1)
                {
                    out.write(data, 0, count);
                }

                out.flush();
                origin.close();
            }
            catch (IOException e)
            {
                System.err.println("Failed to add tar entry due to: " + e.getMessage());
                e.printStackTrace();
            }
        });
    }
}
 

开发者ID:windup,
项目名称:windup,
代码行数:47,
代码来源:TarUtil.java

示例6: TapeArchiveChartWriter

点赞 1

import org.kamranzafar.jtar.TarOutputStream; //导入依赖的package包/类
/**
 * Creates a new {@link TapeArchiveChartWriter}.
 *
 * @param outputStream the {@link OutputStream} to write to; must
 * not be {@code null} and should be buffered at some level
 *
 * @see
 * AbstractArchiveChartWriter#AbstractArchiveChartWriter()
 *
 * @see TarOutputStream#TarOutputStream(OutputStream)
 */
public TapeArchiveChartWriter(final OutputStream outputStream) {
  super();
  Objects.requireNonNull(outputStream);
  this.outputStream = new TarOutputStream(outputStream);
}
 

开发者ID:microbean,
项目名称:microbean-helm,
代码行数:17,
代码来源:TapeArchiveChartWriter.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)