Merge pull request #11231 from eugenp/BAEL-5033-v2
BAEL-5033 create file if it doesn't exist
This commit is contained in:
commit
8bb4493d55
|
@ -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