當前位置: 首頁>>代碼示例>>Java>>正文


Java ZipUtil.pack方法代碼示例

本文整理匯總了Java中org.zeroturnaround.zip.ZipUtil.pack方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipUtil.pack方法的具體用法?Java ZipUtil.pack怎麽用?Java ZipUtil.pack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.zeroturnaround.zip.ZipUtil的用法示例。


在下文中一共展示了ZipUtil.pack方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
@Override
public File write(Package pkg, File targetDirectory) {
	PackageMetadata packageMetadata = pkg.getMetadata();
	File tmpDir = TempFileUtils.createTempDirectory("skipper" + packageMetadata.getName()).toFile();
	File rootPackageDir = new File(tmpDir,
			String.format("%s-%s", packageMetadata.getName(), packageMetadata.getVersion()));
	rootPackageDir.mkdir();
	writePackage(pkg, rootPackageDir);
	if (!pkg.getDependencies().isEmpty()) {
		File packagesDir = new File(rootPackageDir, "packages");
		packagesDir.mkdir();
		for (Package dependencyPkg : pkg.getDependencies()) {
			File packageDir = new File(packagesDir, dependencyPkg.getMetadata().getName());
			packageDir.mkdir();
			writePackage(dependencyPkg, packageDir);
		}
	}
	File targetZipFile = PackageFileUtils.calculatePackageZipFile(pkg.getMetadata(), targetDirectory);
	ZipUtil.pack(rootPackageDir, targetZipFile, true);
	FileSystemUtils.deleteRecursively(tmpDir);
	return targetZipFile;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:23,代碼來源:DefaultPackageWriter.java

示例2: createZipPackage

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
protected File createZipPackage() throws Exception {
    logInfo("");
    logInfo(CREATE_ZIP_START);

    final String stageDirectoryPath = mojo.getDeploymentStageDirectory();
    final File stageDirectory = new File(stageDirectoryPath);
    final File zipPackage = new File(stageDirectoryPath.concat(ZIP_EXT));

    if (!stageDirectory.exists()) {
        logError(STAGE_DIR_NOT_FOUND);
        throw new Exception(STAGE_DIR_NOT_FOUND);
    }

    ZipUtil.pack(stageDirectory, zipPackage);

    logDebug(REMOVE_LOCAL_SETTINGS);
    ZipUtil.removeEntry(zipPackage, LOCAL_SETTINGS_FILE);

    logInfo(CREATE_ZIP_DONE + stageDirectoryPath.concat(ZIP_EXT));
    return zipPackage;
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:22,代碼來源:MSDeployArtifactHandlerImpl.java

示例3: compressZIP

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
/**
 * Compress a list of WorkflowRevision into a ZIP archive
 * @param workflowsList the list of workflows to compress
 * @return a byte array corresponding to the archive containing the workflows
 */
public byte[] compressZIP(List<WorkflowRevision> workflowsList) {

    if (workflowsList == null || workflowsList.size() == 0) {
        return null;
    }

    try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {

        Stream<ZipEntrySource> streamSources = workflowsList.stream()
                                                            .map(workflowRevision -> new ByteSource(getName(workflowRevision),
                                                                                                    workflowRevision.getXmlPayload()));
        ZipEntrySource[] sources = streamSources.toArray(size -> new ZipEntrySource[size]);
        ZipUtil.pack(sources, byteArrayOutputStream);

        return byteArrayOutputStream.toByteArray();
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

}
 
開發者ID:ow2-proactive,項目名稱:workflow-catalog-old,代碼行數:26,代碼來源:ArchiveManagerHelper.java

示例4: compress

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
/****
 * 
 * @param root
 * @throws IOException
 */
public static byte[] compress(File root) throws IOException {
  if (root.exists()) {
    File zip = new File(Files.createTempDir(), "data.zip");
    
    ZipUtil.pack(root, zip, new NameMapper() {
      @Override
      public String map(String name) {
        // Filter out the socket files... 
        if (name.endsWith(".sock"))
          return null;
        else 
          return name;
      }
    });
        
    byte[] data = Files.toByteArray(zip);
    zip.delete();
    return data;
  } else {
    _log.warn("no data to compress: " + root.toString());
    return new byte[] {};
  }
}
 
開發者ID:zillabyte,項目名稱:motherbrain,代碼行數:29,代碼來源:CompressUtils.java

示例5: realExport

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
private void realExport(IDatabaseConfiguration config, File zip,
		boolean active) {
	try {
		if (active)
			Database.close();
		if (config instanceof DerbyConfiguration) {
			File folder = DatabaseDir.getRootFolder(config.getName());
			ZipUtil.pack(folder, zip);
		} else if (config instanceof MySQLConfiguration) {
			MySQLDatabaseExport export = new MySQLDatabaseExport(
					(MySQLConfiguration) config, zip);
			export.run();
		}
	} catch (Exception e) {
		log.error("Export failed " + zip, e);
	}
}
 
開發者ID:GreenDelta,項目名稱:olca-app,代碼行數:18,代碼來源:DbExportAction.java

示例6: run

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
@Override
public void run() {
	try {
		IDatabase sourceDb = config.createInstance();
		DerbyDatabase targetDb = createTemporaryDb();
		DatabaseImport io = new DatabaseImport(sourceDb, targetDb);
		io.run();
		sourceDb.close();
		targetDb.close();
		ZipUtil.pack(targetDb.getDatabaseDirectory(), zolcaFile);
		FileUtils.deleteDirectory(targetDb.getDatabaseDirectory());
		success = true;
	} catch (Exception e) {
		success = false;
		log.error("failed export MySQL database as zolca-File", e);
	}
}
 
開發者ID:GreenDelta,項目名稱:olca-app,代碼行數:18,代碼來源:MySQLDatabaseExport.java

示例7: processResult

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
protected void processResult(IEvaluationTask task) {
    String resultPath = task.getResultPath();
    if (ServerRunner.doCompress()) {
        String zipName = resultPath.substring(0, resultPath.length() - 2) + ".zip";
        ZipUtil.pack(new File(resultPath), new File(zipName));
        if (ServerRunner.doDelete()) {
            try {
                FileUtils.deleteDirectory(new File(resultPath));
            } catch (IOException ex) {
                Logger.getLogger(SingleTaskEvaluatorBase.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:15,代碼來源:SingleTaskEvaluatorBase.java

示例8: test2

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
@Test(description = "Проверка чтения дерева логов")
    public void test2() throws ParseException, IOException {
        LogFilesStructure logFilesStructure = new LogFilesStructure();
        String path = "c:\\temp\\";
        Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2017-02-17");
        HashMap<String, ArrayList<String>> logAfterDate = logFilesStructure.getLogAfterDate(date);

        for (HashMap.Entry<String,ArrayList<String>> entry : logAfterDate.entrySet()){
            for (String logPath : entry.getValue()) {
                FileUtils.copyFileToDirectory(new File(logPath),new File(path+"Archive\\"+entry.getKey()+"//"));
//                FileUtils.moveFileToDirectory(new File(logPath),new File(path+entry.getKey()+"//"),true);
            }
        }
        ZipUtil.pack(new File(path+"Archive\\"),new File(path+"archive.zip"));
    }
 
開發者ID:asmodeirus,項目名稱:BackOffice,代碼行數:16,代碼來源:LogFilesStructure.java

示例9: storeMd5s

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
private void storeMd5s(Collection<Path> filePaths) throws IOException {
	Path md5TempPath = appConfig.getBaseServerPath().resolve(MD5_TEMP_PATH);
	filePaths.forEach(filePath -> {
		try {
			Path dirRelativeToBase = appConfig.getSyncPath().relativize(filePath.getParent());
			Path md5FilePath = md5TempPath.resolve(dirRelativeToBase).resolve(filePath.getFileName() + ".md5");

			Files.createDirectories(md5FilePath.getParent());

			Files.write(md5FilePath, computeMd5(filePath));
		} catch (IOException e) {
			LOGGER.warn("Error while computing md5.");
			LogUtil.stacktrace(LOGGER, e);
		}
	});

	OnlyContentZipEntrySource[] zipEntries = Files.walk(md5TempPath)
			.filter(not(Files::isDirectory))
			.map(file -> {
				Path relativeToBase = md5TempPath.relativize(file);
				return new OnlyContentZipEntrySource(relativeToBase.toString(), file.toFile());
			})
			.toArray(OnlyContentZipEntrySource[]::new);

	Path md5File = appConfig.getBaseServerPath().resolve(MD5_FILE);
	ZipUtil.pack(zipEntries, md5File.toFile());

	ftpStoreFile(MD5_FILE, Files.newInputStream(md5File));
}
 
開發者ID:Azzurite,項目名稱:MinecraftServerSync,代碼行數:30,代碼來源:FTPSyncClient.java

示例10: backupCurrentFiles

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
private void backupCurrentFiles() throws IOException {
	LOGGER.info("Backing up previous data...");

	OnlyContentZipEntrySource[] zipEntries = findLocalServerFiles().stream()
			.map(file -> {
				Path relativeToBase = appConfig.getBaseServerPath().relativize(file);
				return new OnlyContentZipEntrySource(relativeToBase.toString(), file.toFile());
			})
			.toArray(OnlyContentZipEntrySource[]::new);
	Path backupZip = appConfig.getBackupPath().resolve(BACKUP_FILE_ZIP);
	ZipUtil.pack(zipEntries, backupZip.toFile());

	LOGGER.info("Backed up previous data at '{}'.", backupZip);
}
 
開發者ID:Azzurite,項目名稱:MinecraftServerSync,代碼行數:15,代碼來源:ServerSynchronizer.java

示例11: zipSmallFiles

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
private Path zipSmallFiles(Collection<Path> localServerFiles) {
	List<Path> smallFiles = filterForSmallFiles(localServerFiles);
	OnlyContentZipEntrySource[] smallFileZipEntries = smallFiles.stream()
			.map(smallFile -> {
				Path relativeToBase = appConfig.getBaseServerPath().relativize(smallFile);
				return new OnlyContentZipEntrySource(relativeToBase.toString(), smallFile.toFile());
			})
			.toArray(OnlyContentZipEntrySource[]::new);
	Path smallFilesZip = appConfig.getSyncPath().resolve(SMALL_FILES_ZIP);
	ZipUtil.pack(smallFileZipEntries, smallFilesZip.toFile());
	return smallFilesZip;
}
 
開發者ID:Azzurite,項目名稱:MinecraftServerSync,代碼行數:13,代碼來源:ServerSynchronizer.java

示例12: pack

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
@Override
protected void pack() throws Exception
{
    LocalDateTime now = LocalDateTime.now( );
    String dateFormat = now.format(formatter);
    String srcFolder = backupStruct.getTargetPath( ) + File.separator + GRAYLOG_SCHEMA_NAME;
    String dstFolder = backupStruct.getTargetPath( ) + File.separator + GRAYLOG_SCHEMA_NAME + dateFormat + ".zip";
    ZipUtil.pack(new File(srcFolder), new File(dstFolder));
    LOG.info("Graylog config backup completed");
    FileUtils.deleteDirectory(new File(srcFolder));
}
 
開發者ID:fbalicchia,項目名稱:graylog-plugin-backup-configuration,代碼行數:12,代碼來源:FsBackupStrategy.java

示例13: createTask

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
@Override
protected Task<Void> createTask() {
    return new Task<Void>() {
        @Override
        protected Void call() throws Exception {
            if (MainApp.getZdsutils().isAuthenticated() && result.isPresent()) {
                String targetId = result.get().getValue().getId();
                String targetSlug = result.get().getValue().getSlug();

                String pathDir = content.getFilePath ();
                updateMessage(Configuration.getBundle().getString("ui.task.zip.label")+" : "+targetSlug+" "+Configuration.getBundle().getString("ui.task.pending.label")+" ...");
                ZipUtil.pack(new File(pathDir), new File(pathDir + ".zip"));
                updateMessage(Configuration.getBundle().getString("ui.task.import.label")+" : "+targetSlug+" "+Configuration.getBundle().getString("ui.task.pending.label")+" ...");
                if(result.get().getValue().getType() == null) {
                    if(!MainApp.getZdsutils().importNewContent(pathDir+ ".zip", result.get().getKey())) {
                        throw new IOException();
                    }
                } else {
                    if(!MainApp.getZdsutils().importContent(pathDir + ".zip", targetId, targetSlug, result.get().getKey())) {
                        throw new IOException();
                    }
                }

                updateMessage(Configuration.getBundle().getString("ui.task.content.sync")+" ...");
                try {
                    MainApp.getZdsutils().getContentListOnline().clear();
                    MainApp.getZdsutils().initInfoOnlineContent("tutorial");
                    MainApp.getZdsutils().initInfoOnlineContent("article");
                } catch (IOException e) {
                    logger.error("Echec de téléchargement des metadonnés des contenus en ligne", e);
                }
            }
            return null;
        }
    };
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:37,代碼來源:UploadContentService.java

示例14: merge

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
@TaskAction
public void merge() throws IOException {
    ModGradleExtension extension = this.getProject().getExtensions().getByType(ModGradleExtension.class);
    File tempMerge = new File(Constants.CACHE_FILES, "tempMerge.jar");
    File tempClean = new File(Constants.CACHE_FILES, "tempClean");
    if (tempMerge.exists()) {
        tempMerge.delete();
    }
    if (tempClean.exists()) {
        FileUtils.deleteDirectory(tempClean);
    }
    processJar(Constants.MINECRAFT_CLIENT_MAPPED_JAR.get(extension), Constants.MINECRAFT_SERVER_MAPPED_JAR.get(extension), tempMerge);

    ZipUtil.unpack(tempMerge, tempClean, name -> {
        if (name.startsWith("net/minecraft") || name.startsWith("assets") || name.startsWith("log4j2.xml") || (name.endsWith(".class") && !name.contains("/"))) {
            return name;
        } else {
            return null;
        }
    });
    ZipUtil.pack(tempClean, Constants.MINECRAFT_MERGED.get(extension));
    if (tempMerge.exists()) {
        tempMerge.delete();
    }
    if (tempClean.exists()) {
        FileUtils.deleteDirectory(tempClean);
    }
}
 
開發者ID:OpenModLoader,項目名稱:ModGradle,代碼行數:29,代碼來源:MergeJarsTask.java

示例15: zipPack

import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
/**
 * @description: 壓縮並返回zip路徑
 * @author: chenshiqiang E-mail:[email protected]
 * @param track
 * @return
 */
public static String zipPack(Track track){
	if(createXml(track) != null){
		String trackPath = PathConstants.getTrackpath()
				+ File.separator + track.getUniqueMack();
		String zipPath = PathConstants.getExportpath() 
				+ File.separator + StringUtils.filterIllegalWords(track.getName()) 
				+ ".tsa";
		ZipUtil.pack(new File(trackPath), new File(zipPath), true);
		return zipPath;
	}
	return null;
}
 
開發者ID:jp1017,項目名稱:TheSceneryAlong,代碼行數:19,代碼來源:TrackUtil.java


注:本文中的org.zeroturnaround.zip.ZipUtil.pack方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。