Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def unzipFile(File file) {
- cleanupFolder()
- def zipFile = new ZipFile(file)
- zipFile.entries().each { it ->
- def path = Paths.get('c:\\folder\\' + it.name)
- if(it.directory){
- Files.createDirectories(path)
- }
- else {
- def parentDir = path.getParent()
- if (!Files.exists(parentDir)) {
- Files.createDirectories(parentDir)
- }
- Files.copy(zipFile.getInputStream(it), path)
- }
- }
- }
- private cleanupFolder() {
- FileUtils.deleteDirectory(new File('c:\\folder\\'))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement