This commit is contained in:
Yueyu 2021-04-28 06:02:36 +08:00
parent 7b70938394
commit 0a1907564a

View file

@ -119,11 +119,11 @@ public class ScratchJrUtil {
*/ */
public static boolean zipFileAtPath(String sourcePath, String toLocation) { public static boolean zipFileAtPath(String sourcePath, String toLocation) {
File sourceFile = new File(sourcePath); File sourceFile = new File(sourcePath);
if (sourceFile.exists()) {
sourceFile.delete();
}
try { try {
BufferedInputStream origin; BufferedInputStream origin;
// we don't need to remove file at `toLocation`
// because `FileOutputStream` will overwrite the file
// if no `append` parameter is passed
FileOutputStream dest = new FileOutputStream(toLocation); FileOutputStream dest = new FileOutputStream(toLocation);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream( ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
dest)); dest));