Skip to content

Commit

Permalink
wipe cache
Browse files Browse the repository at this point in the history
  • Loading branch information
cubewhy committed Jan 20, 2024
1 parent d9911d3 commit 2f09ecb
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/main/java/org/cubewhy/celestial/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
Expand Down Expand Up @@ -54,4 +56,26 @@ public static void unZip(File input, File outputDir) throws IOException {
}
zipfile.close();
}

public static boolean deleteDir(File folder) {
try {
Files.walkFileTree(folder.toPath(), EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
log.error(TextUtils.dumpTrace(e));
return false;
}
return true;
}
}

0 comments on commit 2f09ecb

Please sign in to comment.