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


Java ZipFile.createZipFileFromFolder方法代碼示例

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


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

示例1: zipFixture

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
public static File zipFixture(String path) throws ZipException {
    File source = new File(path);
    File target = new File("target/archives/zip-archive-test.zip");
    if (target.exists() && !target.delete())
        throw new RuntimeException("Unable to delete old zip file target");

    if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
        throw new RuntimeException("Unable to create directories for zip file target");

    ZipFile zipFile = new ZipFile(target);
    ZipParameters parameters = new ZipParameters();
    parameters.setIncludeRootFolder(false);
    zipFile.createZipFileFromFolder(source, parameters, false, -1);

    return target;
}
 
開發者ID:ozwolf-software,項目名稱:raml-mock-server,代碼行數:17,代碼來源:Fixtures.java

示例2: fakeData

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
private MockMultipartFile fakeData() throws IOException, ZipException {
    File file = testFolder.newFile();
    Files.delete(file.toPath());
    ZipFile zipFile = new ZipFile(file);
    File dir = testFolder.newFolder();
    File metadata = Paths.get(dir.getAbsolutePath(), "metadata.json").toFile();
    FileUtils.writeStringToFile(metadata, "metadata");
    // Add some random files
    File c1 = Paths.get(dir.getAbsolutePath(), "r", "a").toFile();
    File c2 = Paths.get(dir.getAbsolutePath(), "a", "c", "b").toFile();
    FileUtils.writeStringToFile(c1, "c1");
    FileUtils.writeStringToFile(c2, "c2");
    //Zip
    ZipParameters zipParameters = new ZipParameters();
    zipParameters.setIncludeRootFolder(false);
    zipFile.createZipFileFromFolder(dir, zipParameters, false, 0);
    MockMultipartFile mock = new MockMultipartFile("file", Files.newInputStream(zipFile.getFile().toPath()));
    return mock;
}
 
開發者ID:SEEG-Oxford,項目名稱:ABRAID-MP,代碼行數:20,代碼來源:ModelRunControllerTest.java

示例3: CreateSplitZipFileFromFolder

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
public CreateSplitZipFileFromFolder() {
	
	try {
		// Initiate ZipFile object with the path/name of the zip file.
		ZipFile zipFile = new ZipFile("c:\\ZipTest\\CreateSplitZipFileFromFolder.zip");
		
		// Initiate Zip Parameters which define various properties such
		// as compression method, etc.
		ZipParameters parameters = new ZipParameters();
		
		// set compression method to store compression
		parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
		
		// Set the compression level. This value has to be in between 0 to 9
		parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
		
		// Create a split file by setting splitArchive parameter to true
		// and specifying the splitLength. SplitLenth has to be greater than
		// 65536 bytes
		// Please note: If the zip file already exists, then this method throws an 
		// exception
		zipFile.createZipFileFromFolder("C:\\ZipTest", parameters, true, 10485760);
	} catch (ZipException e) {
		e.printStackTrace();
	}

}
 
開發者ID:joielechong,項目名稱:Zip4jAndroid,代碼行數:28,代碼來源:CreateSplitZipFileFromFolder.java

示例4: createConfigPackageFile

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
/**
 * Create an confPackage zip using the sample confPackage located in
 * src/test/resources/testConfPackage/testConfPackageSrc.
 *
 * @param file The file whose path will be used to create the confPackage zip
 * @return The File object that can be used in the ConfigPackage constructor.
 * @throws net.lingala.zip4j.exception.ZipException
 */
public static File createConfigPackageFile(File file) throws net.lingala.zip4j.exception.ZipException
{
  ZipFile zipFile = new ZipFile(file);
  ZipParameters zipParameters = new ZipParameters();
  zipParameters.setIncludeRootFolder(false);
  zipFile.createZipFileFromFolder("src/test/resources/testConfigPackage/testConfigPackageSrc", zipParameters, false, Long.MAX_VALUE);
  return file;
}
 
開發者ID:apache,項目名稱:apex-core,代碼行數:17,代碼來源:StramTestSupport.java

示例5: uploadVersion

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
public void uploadVersion(Version version, int id) throws ZipException, IOException {
	HttpPost post = new HttpPost(url + "ai/" + id + "/upload_zip");
	File file = new File(System.getProperty("java.io.tmpdir"), version.ai.title + "v" + version.number + System.currentTimeMillis() + ".zip");
	ZipFile zip = new ZipFile(file);
	ZipParameters params = new ZipParameters();
	params.setIncludeRootFolder(false);
	zip.createZipFileFromFolder(new File(Paths.versionSrc(version)), params, false, -1);
	FileEntity entity = new FileEntity(file);
	post.setEntity(entity);
	HttpResponse response = http.execute(post);
	byte[] output = getOutput(response.getEntity().getContent());
	if (output == null) {
		throw new IOException("Konnte nicht zum Server verbinden");
	}
	if (response.getStatusLine().getStatusCode() != 200)
	{
		if (response.getFirstHeader("Content-Type").getValue().contains("json"))
		{
			JSONObject json = new JSONObject(new String(output, UTF_8));
			String error = json.getString("error");
			throw new IllegalStateException(error);
		}
		else
			throw new IllegalStateException("Irgendetwas ist beim Hochladen schief gelaufen.");
	}
	File image = ((AiSimple) version.ai).getPictureFile();
	changeImage(image, id);

}
 
開發者ID:Turnierserver,項目名稱:Turnierserver,代碼行數:30,代碼來源:WebConnector.java

示例6: createFakeEngineZip

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
private static File createFakeEngineZip(String ivyVersion) throws IOException, ZipException
{
  File zipDir = createFakeEngineDir(ivyVersion);
  File zipFile = new File(zipDir, "fake.zip");
  ZipFile zip = new ZipFile(zipFile);
  zip.createZipFileFromFolder(new File(zipDir, OsgiDir.INSTALL_AREA), new ZipParameters(), false, 0);
  return zipFile;
}
 
開發者ID:axonivy,項目名稱:project-build-plugin,代碼行數:9,代碼來源:TestInstallEngineMojo.java

示例7: buildZip

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
private byte[] buildZip(String content) throws IOException, ZipException {
    File dir = testFolder.newFolder();
    FileUtils.writeStringToFile(Paths.get(dir.getAbsolutePath(), "metadata.json").toFile(), content);
    File zipFile = testFolder.newFile();
    Files.delete(zipFile.toPath());
    ZipFile zip = new ZipFile(zipFile);
    ZipParameters zipParameters = new ZipParameters();
    zipParameters.setIncludeRootFolder(false);
    zip.createZipFileFromFolder(dir, zipParameters, false, 0);
    return FileUtils.readFileToByteArray(zipFile);
}
 
開發者ID:SEEG-Oxford,項目名稱:ABRAID-MP,代碼行數:12,代碼來源:ModelRunControllerIntegrationTest.java

示例8: zipWorkspace

import net.lingala.zip4j.core.ZipFile; //導入方法依賴的package包/類
private void zipWorkspace(Path workingDirectoryPath, Path zipFilePath) throws ZipException {
    ZipFile zip = new ZipFile(zipFilePath.toFile());
    ZipParameters parameters = new ZipParameters();
    parameters.setIncludeRootFolder(false);
    zip.createZipFileFromFolder(workingDirectoryPath.toFile(), parameters, false, 0);
}
 
開發者ID:SEEG-Oxford,項目名稱:ABRAID-MP,代碼行數:7,代碼來源:ModelRunPackageBuilder.java


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