Advertisement
Lilusik

Untitled

Apr 17th, 2019
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.12 KB | None | 0 0
  1. import org.apache.commons.io.FileUtils
  2. import org.apache.tools.ant.util.FileUtils
  3. import java.nio.file.Files
  4. import java.nio.file.Paths
  5. import java.util.zip.ZipFile
  6. def path = 'C:\\Tickets\\...\\'
  7. def s = '.xml'
  8. def unzipFile(File file) {
  9.     cleanupFolder()
  10.     def zipFile = new ZipFile(file)
  11.     zipFile.entries().each { it ->
  12.         def path = Paths.get('c:\\Tickets\\' + it.name)
  13.         if(it.directory){
  14.             Files.createDirectories(path)
  15.         }
  16.         else {
  17.             def parentDir = path.getParent()
  18.             if (!Files.exists(parentDir)) {
  19.                 Files.createDirectories(parentDir)
  20.             }
  21.             Files.copy(zipFile.getInputStream(it), path)
  22.         }
  23.     }
  24. }
  25.  
  26. private cleanupFolder() {
  27.     FileUtils.deleteDirectory(new File('c:\\folder\\'))
  28. }
  29. String fileContents = new File(path).text
  30. def Violations = new XmlSlurper().parseText(fileContents)
  31. println Violations.Violation.@'OBJ_SIZE'
  32. size=Violations.Violation.@'OBJ_SIZE'
  33. if (size==1){
  34.     def file = new File('ะก:/Directory1')
  35.     file.mkdir()
  36. } else {def file = new File('ะก:/Directory2')
  37.     file.mkdir()
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement