@Override public void close() throws IOException { in.close(); }
public static void decompressTarGz(File tarGzFile, File destDir) { try { IOUtils.forceMkdir(destDir); TarInputStream tin = new TarInputStream(new GZIPInputStream(new FileInputStream(tarGzFile))); TarEntry tarEntry = tin.getNextEntry(); while (tarEntry != null) { File destPath = new File(destDir, tarEntry.getName()); if (tarEntry.isDirectory()) { IOUtils.forceMkdir(destPath); } else { FileOutputStream fout = new FileOutputStream(destPath); tin.copyEntryContents(fout); fout.close(); } tarEntry = tin.getNextEntry(); } tin.close(); } catch (IOException e) { throw new UncheckedIOException(e); } }
protected void getFileContent(Launcher launcher, String containerId, String filename, OutputStream outputStream) throws IOException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder() .add("cp", containerId + ":" + filename, "-"); ByteArrayOutputStream out = new ByteArrayOutputStream(); int status = launchDockerCLI(launcher, args) .stdout(out).stderr(launcher.getListener().getLogger()).join(); if (status != 0) { throw new IOException("Failed to get file"); } TarInputStream tar = new TarInputStream(new ByteArrayInputStream(out.toByteArray())); tar.getNextEntry(); tar.copyEntryContents(outputStream); tar.close(); }
protected void getFileContent(Launcher launcher, String containerId, String filename, OutputStream outputStream) throws IOException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder() .add("cp", containerId + ":" + filename, "-"); ByteArrayOutputStream out = new ByteArrayOutputStream(); int status = launchDockerCLI(launcher, args) .stdout(out).stderr(launcher.getListener().getLogger()).join(); if (status != 0) { throw new IOException("Failed to get file"); } TarInputStream tar = new TarInputStream(new ByteArrayInputStream(out.toByteArray())); tar.getNextEntry(); tar.copyEntryContents(outputStream); tar.close(); }
private void processTar(InputStream is) throws Exception { TarInputStream inputStream = new TarInputStream(is); try { TarEntry inputEntry = null; do { inputEntry = inputStream.getNextEntry(); if (inputEntry != null && !inputEntry.isDirectory()) { processEntry(inputEntry.getName(), inputStream, (int) inputEntry.getSize()); } } while (inputEntry != null && !abort); } finally { if (inputStream != null) { inputStream.close(); } } }