在Groovy中解压缩文件时遇到问题
我正在尝试从Groovy中的压缩文件解压/解压缩文件。我正在使用shell命令解压(我尝试了几个使用在线找到的java.util.zip库解压的示例,但没有一个成功) 下面是使用shell命令的代码:在Groovy中解压缩文件时遇到问题,groovy,Groovy,我正在尝试从Groovy中的压缩文件解压/解压缩文件。我正在使用shell命令解压(我尝试了几个使用在线找到的java.util.zip库解压的示例,但没有一个成功) 下面是使用shell命令的代码: def soutz = new StringBuilder(), serrz = new StringBuilder() def procz = "unzip -o consall.zip consolidated.xml".ex
def soutz = new StringBuilder(), serrz = new StringBuilder()
def procz = "unzip -o consall.zip consolidated.xml".execute()
procz.consumeProcessOutput(soutz, serrz)
procz.waitFor()
sdc.log.info( "out> $soutz err> $serrz")
这是输出:
out> Archive: /resources/ofac_sdn/temp/consall.zip
inflating: consolidated.xml
err>
但是提取的文件consolidated.xml实际上并没有具体化(无论是在进程运行时还是以后)
此外,waitFor()或waitForOrKill(5000)似乎不起作用,也没有任何区别。
感谢您的建议使用ant builder解压
new AntBuilder().unzip(src: "consall.zip", dest: "./"){
patternset{
include(name: "**/consolidated.xml")
}
}
只是想确保流程有权限写入“/resources/ofac_sdn/temp/”?是否回答了您的问题?这是否回答了您的问题?