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


Java ZipOutputStream类代码示例

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


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

示例1: crearArchivoComprimido

import net.lingala.zip4j.io.ZipOutputStream; //导入依赖的package包/类
public static void crearArchivoComprimido(OutputStream zipStream, List<SubmissionJudge> solutions) {

		
		// Create a buffer for reading the files

		try {
			// Create the ZIP file
			java.util.zip.ZipOutputStream out = new java.util.zip.ZipOutputStream(zipStream);
			// Compress the files
			for (SubmissionJudge solution : solutions) {
				// Add ZIP entry to output stream.
				out.putNextEntry(new ZipEntry(solution.getFilename()));
				// Transfer bytes from the file to the ZIP file
				out.write(solution.getCode().getBytes());
				out.closeEntry();
			}
			out.close();

		} catch (IOException e) {
			System.out.println(e.getMessage());
		}
	}
 
开发者ID:dovier,项目名称:coj-web,代码行数:23,代码来源:FileUtils.java

示例2: crearArchivoDatasets

import net.lingala.zip4j.io.ZipOutputStream; //导入依赖的package包/类
public static void crearArchivoDatasets(OutputStream zipStream, List<DatagenDataset> datasets) {

		// Create a buffer for reading the files

		try {
			// Create the ZIP file
			java.util.zip.ZipOutputStream out = new java.util.zip.ZipOutputStream(zipStream);

			// Compress the files
			for (DatagenDataset dataset : datasets) {
				String nom = dataset.getId() == null ? "data" : String.valueOf(dataset.getId());
				out.putNextEntry(new ZipEntry(nom + ".in"));
				out.write(dataset.getInput().getBytes());

				out.putNextEntry(new ZipEntry(nom + ".out"));
				out.write(dataset.getOutput().getBytes());

				out.closeEntry();
			}
			out.close();

		} catch (IOException e) {
		}
	}
 
开发者ID:dovier,项目名称:coj-web,代码行数:25,代码来源:FileUtils.java

示例3: ZipInputStream

import net.lingala.zip4j.io.ZipOutputStream; //导入依赖的package包/类
public ZipInputStream(InputStream in, String fileName, String pass, String encyptionMethod) throws ZipException {
    super(in);

    zipParameters = new ZipParameters();
    zipParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
    zipParameters.setEncryptFiles(true);

    String encParts[] = encyptionMethod.split("-");

    if( encParts[0].equals("AES")) {
        zipParameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES);
        if (encParts[1].equals("128")) {
            Log.d(TAG, "Encryption AES Strength 128-bit");
            zipParameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_128);
        } else {
            Log.d(TAG, "Encryption AES Strength 256-bit");
            zipParameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256);
        }
    } else {
        zipParameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
        Log.d(TAG, "Standard Encryption");
    }
    // TODO: If password not set, don't run backup?
    zipParameters.setPassword(pass);
    //                                    parameters.setSourceExternalStream(true);
    //                                    parameters.setFileNameInZip(mediaFileName);

    byteOutputStream = new ByteArrayOutputStream(bufferSize);

    zipOutputStream = new ZipOutputStream(byteOutputStream);
    zipOutputStream.putNextEntry(new File(fileName), zipParameters);
    zipOutputStreamFinished = false;
    byteArraySize = 0;

    Log.d(TAG,"New zip file: "+fileName);

}
 
开发者ID:bright-tools,项目名称:androidphotobackup,代码行数:39,代码来源:ZipInputStream.java


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