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


Java Archiver.extract方法代码示例

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


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

示例1: extractFile

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
/**
 * Extract all files from pathFile to the dirName folder
 *
 * @param pathFile
 * @param dirName
 * @param deleteAfter
 * @return
 */
public static boolean extractFile(String pathFile, String dirName, boolean deleteAfter) {
    File file = new File(dirName);
    if (!file.exists() && file.mkdir()) {
        System.out.println("Directory " + dirName + " created!");
        Archiver archiver = ArchiverFactory.createArchiver("tar", "gz");
        try {
            File template = new File(pathFile);
            archiver.extract(template, file);
            System.out.println("Template extracted with success!");

            if (deleteAfter && template.delete()) {
                System.out.println("Temporary file deleted!");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        return true;
    }

    System.out.println("Error: " + dirName + " already exists!");

    return false;
}
 
开发者ID:massivedisaster,项目名称:kickoff,代码行数:33,代码来源:FileUtils.java

示例2: downloadServer

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public void downloadServer(MinecraftServerC server, File serverPath) throws IOException
{
    String existURL = this.instance.getTemplatesDomain() + "servers/exist.php?game=" + server.getGame();

    if (!Boolean.parseBoolean(NetworkUtils.readURL(existURL)))
    {
        throw new IllegalStateException("Server template don't exist!");
    }

    File dest = new File(serverPath, server.getGame() + ".tar.gz");

    FileUtils.copyFile(cacheManager.getServerFiles(server.getGame()), dest);

    Archiver archiver = ArchiverFactory.createArchiver("tar", "gz");
    archiver.extract(dest, serverPath.getAbsoluteFile());
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:17,代码来源:ResourceManager.java

示例3: downloadMap

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public void downloadMap(MinecraftServerC server, File serverPath) throws IOException
{
    String existURL = this.instance.getTemplatesDomain() + "maps/exist.php?game=" + server.getGame() + "&map=" + server.getMap().replaceAll(" ", "_");

    if (!Boolean.parseBoolean(NetworkUtils.readURL(existURL)))
    {
        throw new IllegalStateException("Server's map don't exist! (" + existURL + ")");
    }

    File dest = new File(serverPath, server.getGame() + "_" + server.getMap().replaceAll(" ", "_") + ".tar.gz");

    FileUtils.copyFile(cacheManager.getMapFiles(server.getGame(), server.getMap().replaceAll(" ", "_")), dest);

    Archiver archiver = ArchiverFactory.createArchiver("tar", "gz");
    archiver.extract(dest, serverPath.getAbsoluteFile());
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:17,代码来源:ResourceManager.java

示例4: downloadAndExtractPackage

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public void downloadAndExtractPackage(AmbariEndpoint clusterAmbari) throws IOException {
	if (getPackage_uri() != null) {

		// Check whether the file is already present (do not re-download)
		// We pull the tarball into tmp
		String filePath = getPackageFilepath();
		File file = new File(filePath);
		File dir = new File(getPackageWorkdir(clusterAmbari));
		File svcs = new File(clusterAmbari.getServicesFolder());
		
		if (!file.isFile()) {
			// How can we do this in a thread and provide download
			// update ? TODO
			AmbariStoreHelper.downloadFile(getPackage_uri(), filePath);
		}
		// Remove old folder and unpack into services folder
		FileUtils.deleteDirectory(dir);
		LOG.info("Extracting service package '" + filePath + "' to '" + clusterAmbari.getServicesFolder() + "'.");
		Archiver archiver = ArchiverFactory.createArchiver("tar", "gz");
		archiver.extract(file, svcs);
	}
}
 
开发者ID:jpplayer,项目名称:amstore-view,代码行数:23,代码来源:StoreApplicationService.java

示例5: unzip

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
/**
 * @param targetFile
 * @param destinationFilePath
 * @param format
 * @param type
 */
public static void unzip(String targetFile, String destinationFilePath, ArchiveFormat format, CompressionType type){
	Archiver zip;
	if(type == null)
		zip = ArchiverFactory.createArchiver(format);
	else
		zip = ArchiverFactory.createArchiver(format, type);
	
	File target = new File(targetFile);
	File destination = new File(destinationFilePath);
	try{
		zip.extract(target, destination);
	}catch(IOException e){
		e.printStackTrace();
	}
}
 
开发者ID:matcracker,项目名称:PocketMine-ManagerServers,代码行数:22,代码来源:Zipper.java

示例6: downloadAndExtractGeckoDriver

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
private static void downloadAndExtractGeckoDriver(File directory, String downloadFilenameSuffix,
        String downloadFilenameExt, String optionalExt, Archiver archiver) throws IOException {
    // using System.out to make sure user sees why there is a delay here
    System.out.print("Downloading Mozilla geckodriver " + GECKO_DRIVER_VERSION + " ...");
    URL url = new URL("https://github.com/mozilla/geckodriver/releases/download/v"
            + GECKO_DRIVER_VERSION + "/geckodriver-v" + GECKO_DRIVER_VERSION + '-'
            + downloadFilenameSuffix + '.' + downloadFilenameExt);
    InputStream in = url.openStream();
    File archiveFile = File.createTempFile("geckodriver-" + GECKO_DRIVER_VERSION + '-',
            '.' + downloadFilenameExt);
    Files.asByteSink(archiveFile).writeFrom(in);
    in.close();
    archiver.extract(archiveFile, directory);
    Files.move(new File(directory, "geckodriver" + optionalExt),
            new File(directory, "geckodriver-" + GECKO_DRIVER_VERSION + optionalExt));
    archiveFile.delete();
    System.out.println(" OK");
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:19,代码来源:WebDriverSetup.java

示例7: extractWorld

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
/**
 * Extract the downloaded world in a given destination folder
 *
 * @param worldTar World archive
 * @param worldDir Destination
 *
 * @return {@code true} if success or {@code false}
 */
private static boolean extractWorld(File worldTar, File worldDir)
{
    Archiver archiver = ArchiverFactory.createArchiver("tar", "gz");

    try
    {
        archiver.extract(worldTar, worldDir.getParentFile());
        return true;
    }
    catch (IOException ignored)
    {
        return false;
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:WorldDownloader.java

示例8: downloader

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public void downloader(URL remoteFile, File archive, File dest) throws IOException
{
    //TODO clear cache every day
    NetworkUtils.copyURLToFile(remoteFile, archive);
    Archiver archiver = ArchiverFactory.createArchiver("tar", "gz");
    archiver.extract(archive, dest);
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:8,代码来源:CacheManager.java

示例9: decompressTGZ

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public static void decompressTGZ( File src , File dst ) {
	Archiver archiver = ArchiverFactory.createArchiver("tar", "gz");
	try {
		archiver.extract(src, dst);
	} catch (IOException e) {
		System.out.println("Failed to decompress.  "+e.getMessage());
		System.exit(1);
	}
}
 
开发者ID:lessthanoptimal,项目名称:DeepBoof,代码行数:10,代码来源:DeepBoofDataBaseOps.java

示例10: unTarGz

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public File unTarGz(File archive) throws IOException {
    Archiver archiver = createArchiver(TAR, GZIP);
    archiver.extract(archive, archive.getParentFile());
    log.trace("unTarGz {}", archive);

    return archive;
}
 
开发者ID:bonigarcia,项目名称:webdrivermanager,代码行数:8,代码来源:Downloader.java

示例11: unBZip2

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public File unBZip2(File archive) throws IOException {
    Archiver archiver = createArchiver(TAR, BZIP2);
    archiver.extract(archive, archive.getParentFile());
    log.trace("Unbzip2 {}", archive);

    return archive;
}
 
开发者ID:bonigarcia,项目名称:webdrivermanager,代码行数:8,代码来源:Downloader.java

示例12: downloadAndExtract

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
private static void downloadAndExtract(File baseDir) throws IOException {
    // using System.out to make sure user sees why there is a big delay here
    System.out.print("Downloading Cassandra " + CASSANDRA_VERSION + " ...");
    URL url = new URL("http://www.apache.org/dist/cassandra/" + CASSANDRA_VERSION
            + "/apache-cassandra-" + CASSANDRA_VERSION + "-bin.tar.gz");
    InputStream in = url.openStream();
    File archiveFile = File.createTempFile("cassandra-" + CASSANDRA_VERSION + "-", ".tar.gz");
    Files.asByteSink(archiveFile).writeFrom(in);
    in.close();
    Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
    archiver.extract(archiveFile, baseDir);
    archiveFile.delete();
    System.out.println(" OK");

    File cassandraDir = new File(baseDir, "apache-cassandra-" + CASSANDRA_VERSION);
    File confDir = new File(cassandraDir, "conf");
    // reduce logging to stdout
    File logbackXmlFile = new File(confDir, "logback.xml");
    String xml = Files.asCharSource(logbackXmlFile, Charsets.UTF_8).read();
    xml = xml.replace("<root level=\"INFO\">", "<root level=\"ERROR\">");
    xml = xml.replace("<logger name=\"org.apache.cassandra\" level=\"DEBUG\"/>", "");
    Files.asCharSink(logbackXmlFile, Charsets.UTF_8).write(xml);
    // long timeouts needed on slow travis ci machines
    File yamlFile = new File(confDir, "cassandra.yaml");
    String yaml = Files.asCharSource(yamlFile, Charsets.UTF_8).read();
    yaml = yaml.replaceAll("(?m)^read_request_timeout_in_ms: .*$",
            "read_request_timeout_in_ms: 30000");
    yaml = yaml.replaceAll("(?m)^write_request_timeout_in_ms: .*$",
            "write_request_timeout_in_ms: 30000");
    Files.asCharSink(yamlFile, Charsets.UTF_8).write(yaml);
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:32,代码来源:CassandraWrapper.java

示例13: downloadAndExtract

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
private static void downloadAndExtract(File baseDir) throws IOException {
    // using System.out to make sure user sees why there is a big delay here
    System.out.print("Downloading Cassandra " + CASSANDRA_VERSION + " ...");
    URL url = new URL("http://www.apache.org/dist/cassandra/" + CASSANDRA_VERSION
            + "/apache-cassandra-" + CASSANDRA_VERSION + "-bin.tar.gz");
    InputStream in = url.openStream();
    File archiveFile = File.createTempFile("cassandra-" + CASSANDRA_VERSION + "-", ".tar.gz");
    Files.asByteSink(archiveFile).writeFrom(in);
    in.close();
    Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
    archiver.extract(archiveFile, baseDir);
    archiveFile.delete();
    System.out.println(" OK");

    File cassandraDir = new File(baseDir, "apache-cassandra-" + CASSANDRA_VERSION);
    File confDir = new File(cassandraDir, "conf");
    // reduce logging to stdout
    File logbackXmlFile = new File(confDir, "logback.xml");
    String xml = Files.toString(logbackXmlFile, Charsets.UTF_8);
    xml = xml.replace("<root level=\"INFO\">", "<root level=\"ERROR\">");
    xml = xml.replace("<logger name=\"org.apache.cassandra\" level=\"DEBUG\"/>", "");
    Files.asCharSink(logbackXmlFile, Charsets.UTF_8).write(xml);
    // long timeouts needed on slow travis ci machines
    File yamlFile = new File(confDir, "cassandra.yaml");
    String yaml = Files.toString(yamlFile, Charsets.UTF_8);
    yaml = yaml.replaceAll("(?m)^read_request_timeout_in_ms: .*$",
            "read_request_timeout_in_ms: 30000");
    yaml = yaml.replaceAll("(?m)^write_request_timeout_in_ms: .*$",
            "write_request_timeout_in_ms: 30000");
    Files.asCharSink(yamlFile, Charsets.UTF_8).write(yaml);
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:32,代码来源:CassandraWrapper.java

示例14: unpackContent

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
public void unpackContent() throws IOException {
	if (getVersion()==4) {
		Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
		unpackFolder=new File(sinfile.getParent()+File.separator+Category.getCategoryFromName(sinfile.getName()));
		unpackFolder.mkdirs();
		logger.info("Extracting sin content to "+Category.getCategoryFromName(sinfile.getName()));
		archiver.extract(sinfile.getAbsoluteFile(), unpackFolder);
	}
}
 
开发者ID:Androxyde,项目名称:Flashtool,代码行数:10,代码来源:SinFile.java

示例15: handleFile

import org.rauschig.jarchivelib.Archiver; //导入方法依赖的package包/类
/**
 * Processes a file. If the file is an archive (zip, tar.gz, tgz), it is extracted to a
 * directory with the name of the archive file. Otherwise, the file is copied to the destination
 * directory.
 */
@Override
protected void handleFile(final File file, final int depth, final Collection<File> results) throws IOException {
	String fileName = file.getName();

	File targetDir = new File(normalizedDestDirPath, currentNormalizedRelativeDirPath);
	if (!targetDir.exists()) {
		checkState(targetDir.mkdirs(), "Could not create directory: " + targetDir);
	}

	Matcher matcher = ARCHIVE_PATTERN.matcher(fileName);
	if (matcher.find()) {
		log.debug("Extracting file: {}", file);

		try {
			String extension = matcher.group();
			String baseName = StringUtils.substringBeforeLast(fileName, extension);
			Archiver archiver = ArchiverFactory.createArchiver(file);
			archiver.extract(file, new File(targetDir, baseName));
		} catch (IOException ex) {
			log.error("Error extracting file: " + file, ex);
		}
	} else {
		log.debug("Copying file: {}", file);

		// We skip supervisor.log because the Supervisor might be running perfAlyzer
		// and the file could be locked. The file is not needed anyways.
		if (!"supervisor.log".equals(file.getName())) {
			FileUtils.copyFile(file, new File(targetDir, fileName));
		}
	}
}
 
开发者ID:mgm-tp,项目名称:perfload-perfalyzer,代码行数:37,代码来源:ArchiveExtracter.java


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