List of usage examples for com.google.common.io ByteSink writeFrom
public long writeFrom(InputStream input) throws IOException
From source file:org.queeg.hadoop.tar.TarExtractor.java
public void extract(ByteSource source) throws IOException { TarArchiveInputStream archiveInputStream = new TarArchiveInputStream(source.openStream()); TarArchiveEntry entry;//from w w w . ja va 2 s. c om while ((entry = archiveInputStream.getNextTarEntry()) != null) { if (entry.isFile()) { BoundedInputStream entryInputStream = new BoundedInputStream(archiveInputStream, entry.getSize()); ByteSink sink = new PathByteSink(conf, new Path(destination, entry.getName())); sink.writeFrom(entryInputStream); } else if (entry.isDirectory()) { ByteStreams.skipFully(archiveInputStream, entry.getSize()); fs.mkdirs(new Path(destination, entry.getName())); } } archiveInputStream.close(); }