本文整理汇总了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());
}
}
示例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) {
}
}
示例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);
}