BAEL-5033 create file if it doesn't exist
This commit is contained in:
parent
8c7827bebd
commit
656c697f4c
|
@ -18,9 +18,12 @@ public class ZipMultiFile {
|
|||
|
||||
File firstFile = new File("aFile.txt");
|
||||
File secondFile = new File("bFile.txt");
|
||||
|
||||
firstFile.createNewFile();
|
||||
secondFile.createNewFile();
|
||||
if (!firstFile.exists()) {
|
||||
firstFile.createNewFile();
|
||||
}
|
||||
if (!secondFile.exists()) {
|
||||
secondFile.createNewFile();
|
||||
}
|
||||
|
||||
List<File> filesToAdd = Arrays.asList(firstFile, secondFile);
|
||||
|
||||
|
|
|
@ -16,7 +16,12 @@ public class ZipSingleFile {
|
|||
zipParameters.setCompressionLevel(CompressionLevel.HIGHER);
|
||||
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
|
||||
ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray());
|
||||
zipFile.addFile(new File("aFile.txt"));
|
||||
|
||||
File fileToAdd = new File("aFile.txt");
|
||||
if (!fileToAdd.exists()) {
|
||||
fileToAdd.createNewFile();
|
||||
}
|
||||
zipFile.addFile(fileToAdd);
|
||||
zipFile.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue