import org.apache.commons.compress.archivers.tar.*
import org.apache.commons.compress.utils.*
is = new BufferedInputStream(new FileInputStream("test.tar"))
tais = new TarArchiveInputStream(is, 8192)
dest = ".\\out\\"
while((ent = tais.getNextTarEntry()) != null){
println dest + ent.getName()
df = new File(dest + ent.getName())
if( ent.isDirectory() ){
df.mkdirs()
} else {
if( df.getParentFile().exists() == false ){
df.getParentFile().mkdirs()
}
OutputStream out = new FileOutputStream(df)
IOUtils.copy(tais, out, 8192)
out.close()
}
}
tais.close()
is.close()
動作環境
groovy 1.7.4, JDK6 Update21, Apache Commons Compress 1.1
0 件のコメント:
コメントを投稿