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


Java Archiver类代码示例

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


Archiver类属于org.rauschig.jarchivelib包,在下文中一共展示了Archiver类的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: getControlTarGzFromDeb

import org.rauschig.jarchivelib.Archiver; //导入依赖的package包/类
protected File getControlTarGzFromDeb(File debFile, File ephemeralTempDir) throws IOException {
	
	Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.AR);
	ArchiveStream stream = archiver.stream(debFile);
	ArchiveEntry entry;
	
	File controlTarGzFile = null;

	while((entry = stream.getNextEntry()) != null) {
		if ("control.tar.gz".equals(entry.getName())){
			controlTarGzFile = entry.extract(ephemeralTempDir);
		}
	}
	stream.close();
	
	return controlTarGzFile;
}
 
开发者ID:tcplugins,项目名称:tcDebRepository,代码行数:18,代码来源:DebFileReader.java

示例5: getControlFromControlTarGz

import org.rauschig.jarchivelib.Archiver; //导入依赖的package包/类
protected String getControlFromControlTarGz(File controlTarGzFile) throws IOException {
	Archiver archivertgz = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
	ArchiveStream stream = archivertgz.stream(controlTarGzFile);
	ArchiveEntry entry;
	ByteArrayOutputStream baos= new ByteArrayOutputStream();
	
	while((entry = stream.getNextEntry()) != null) {
		if ("./control".equals(entry.getName())){
			IOUtils.copy(stream, baos);
		}
	}
	
	stream.close();
	
	return baos.toString( StandardCharsets.UTF_8.toString() );
}
 
开发者ID:tcplugins,项目名称:tcDebRepository,代码行数:17,代码来源:DebFileReader.java

示例6: getStream

import org.rauschig.jarchivelib.Archiver; //导入依赖的package包/类
@Test
public void getStream() throws IOException {
	
	Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.AR);
	ArchiveStream stream = archiver.stream(new File("src/test/resources/build-essential_11.6ubuntu6_amd64.deb"));
	org.rauschig.jarchivelib.ArchiveEntry entry;
	

	while((entry = stream.getNextEntry()) != null) {
	    // access each archive entry individually using the stream
	    // or extract it using entry.extract(destination)
	    // or fetch meta-data using entry.getName(), entry.isDirectory(), ...
		System.out.println(entry.getName());
		if (entry.getName().equals("control.tar.gz")){
			//ArchiveStream controlTarGzStream = archivertgz.stream(entry.);
			
		}
	}
	stream.close();
}
 
开发者ID:tcplugins,项目名称:tcDebRepository,代码行数:21,代码来源:ArStreamerTest.java

示例7: getControlStringFromArFile

import org.rauschig.jarchivelib.Archiver; //导入依赖的package包/类
public String getControlStringFromArFile(File arFile) throws IOException {
	Archiver archiverAr = ArchiverFactory.createArchiver(ArchiveFormat.AR);
	Archiver archivertgz = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
	ArchiveStream stream = archiverAr.stream(arFile);
	ArchiveEntry entry, entry2;
	ByteArrayOutputStream baos= new ByteArrayOutputStream();
	
	while((entry = stream.getNextEntry()) != null) {
		// The ar contains a tgz file named control.tar.gz
		if (entry.getName().equals("control.tar.gz")) {
			ArchiveStream stream2 = null; //archivertgz.stream(entry);
			while((entry2 = stream2.getNextEntry()) != null) {
				//The control.tar.gz contains a text file named control 
				if (entry2.getName().equals("./control")){
					IOUtils.copy(stream2, baos);
				}
			}
		}
	}
	
	return baos.toString( StandardCharsets.UTF_8.toString() );
}
 
开发者ID:tcplugins,项目名称:tcDebRepository,代码行数:23,代码来源:ArStreamerTest.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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