在gradle中使用的时候碰到了上边的错误,原本的代码如下
def tmp = File.createTempFile("temp_${System.nanoTime()}", '.zip')
tmp.withOutputStream { os ->
def zos = new ZipOutputStream(os)
zin.entries().each { entry ->
def isReplaced = entry.name == zipEntry
println("isReplaced->"+isReplaced)
if(isReplaced) {
entry.setComment(newContent)
}
zos.putNextEntry(entry)
zos << (zin.getInputStream(entry).bytes)
zos.closeEntry()
}
zos.close()
}
zin.close()
新代码如下
def tmp = File.createTempFile("temp_${System.nanoTime()}", '.zip')
tmp.withOutputStream { os ->
def zos = new ZipOutputStream(os)
zin.entries().each { entry ->
ZipEntry newZipEntry = new ZipEntry(entry.getName())
def isReplaced = newZipEntry.name == zipEntry
println("isReplaced->"+isReplaced)
if(isReplaced) {
newZipEntry.setComment(newContent)
}
zos.putNextEntry(newZipEntry)
zos << (zin.getInputStream(newZipEntry).bytes)
zos.closeEntry()
}
zos.close()
}
zin.close()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)