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


Java UntarCompressionMethod类代码示例

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


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

示例1: execute

import org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
    try {
        Utils.setProject(getProject());
        log("trying native untar");
        
        Utils.nativeUntar(source, dest);
    } catch (IOException e) {
        log("native untar failed, falling back to java implementation");
        
        Utils.delete(dest);
        UntarCompressionMethod compression = new UntarCompressionMethod();
        if(source.getName().endsWith(".tar.gz") || source.getName().endsWith(".tgz")) {
            compression.setValue("gzip");
        } else if(source.getName().endsWith(".tar.bz2") || source.getName().endsWith(".tar.bzip2")) {
            compression.setValue("bzip2");
        } else {
            compression.setValue("none");
        }
        setCompression(compression);
        super.execute();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:NativeUntar.java

示例2: compressionMethod

import org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod; //导入依赖的package包/类
/**
 * Internal convenience method determines the archive type from the filename
 * extension.
 */
private static UntarCompressionMethod compressionMethod(File file) {
  String fn = file.toString();
  UntarCompressionMethod out = new UntarCompressionMethod();

  if (fn.endsWith("gz")) {
    out.setValue("gzip");
  } else if (fn.endsWith("bz2")) {
    out.setValue("bzip2");
  } else if (fn.endsWith("tar")) {
    out.setValue("none");
  } else {
    throw new IllegalArgumentException("UntarJob doesn't know what to do with that file. "
        + "tar, gz, and bz2 files accepted.");
  }
  return out;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:UntarRunnable.java

示例3: ABoaIndex

import org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod; //导入依赖的package包/类
/**
 *
 * Constructor.
 *
 * @param file boa index
 */
public ABoaIndex(final String lang) {
  this.lang = lang;

  luceneIndexFolder = "data/boa/" + lang;
  if (!Files.exists(Paths.get(luceneIndexFolder))) {

    final File tarFile = Paths.get("data/boa/boa_" + lang + "_10.tar.gz").toFile();
    final Project p = new Project();
    final Untar ut = new Untar();
    ut.setProject(p);
    ut.setSrc(tarFile);
    if (tarFile.getName().endsWith(".gz")) {
      ut.setCompression((UntarCompressionMethod) EnumeratedAttribute
          .getInstance(UntarCompressionMethod.class, "gzip"));
    }
    ut.setDest(Paths.get(luceneIndexFolder).toFile());
    ut.perform();
  }

  createSupportedBoaRelations();
}
 
开发者ID:dice-group,项目名称:FOX,代码行数:28,代码来源:ABoaIndex.java

示例4: untarFile

import org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod; //导入依赖的package包/类
public static void untarFile(File tarFile, File destDir) throws IOException {
    Untarer untar = new Untarer();
    Untar.UntarCompressionMethod compMethod = new UntarCompressionMethod();
    compMethod.setValue("gzip");
    untar.setCompression(compMethod);
    untar.setDest(destDir);
    untar.setSrc(tarFile);
    untar.execute();

    // now that the work is done, use file utils to
    // move everything out of destDir/tarFileNoExt
    // into destDir
    // then delete destDir/tarFileNoExt
    String wrongInstallDir = destDir.getCanonicalPath() + File.separator
            + getFileNameNoExt(tarFile.getName());
    FileUtils.copyDirectory(new File(wrongInstallDir), destDir, true);

    // grrr java IO, love it
    // because it sucks, we have to CHMOD everything in destDir/bin
    File binDir = new File(destDir.getCanonicalPath() + File.separator
            + "bin");
    Chmoder chmod = new Chmoder();
    chmod.setDir(binDir);
    chmod.setPerm("ugo+rx");
    chmod.setIncludes("*");
    chmod.execute();

    deleteAllFilesAndDir(new File(wrongInstallDir));

}
 
开发者ID:apache,项目名称:oodt,代码行数:31,代码来源:AntDecorator.java


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