public class StreamUtils extends Object
| Constructor and Description |
|---|
StreamUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
byteBufferToOutputStream(ByteBuffer in,
OutputStream out)
Reads the full contents of a ByteBuffer and writes them to an OutputStream.
|
static org.apache.hadoop.fs.FSDataInputStream |
convertStream(InputStream in)
|
static long |
copy(InputStream is,
OutputStream os)
|
static long |
copy(ReadableByteChannel inputChannel,
WritableByteChannel outputChannel)
Copies a
ReadableByteChannel to a WritableByteChannel. |
static boolean |
isCompressed(byte[] bytes) |
static void |
tar(org.apache.hadoop.fs.FileSystem sourceFs,
org.apache.hadoop.fs.FileSystem destFs,
org.apache.hadoop.fs.Path sourcePath,
org.apache.hadoop.fs.Path destPath)
Similiar to
tar(FileSystem, Path, Path) except the source and destination FileSystem can be different. |
static void |
tar(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path sourcePath,
org.apache.hadoop.fs.Path destPath)
Creates a tar gzip file using a given
Path as input and a given Path as a destination. |
public static org.apache.hadoop.fs.FSDataInputStream convertStream(InputStream in) throws IOException
IOExceptionSeekableFSInputStreampublic static long copy(InputStream is, OutputStream os) throws IOException
InputStream to and OutputStream using Channels.
Note: The method does not close the InputStream and OutputStream. However, the
ReadableByteChannel and WritableByteChannels are closed
IOExceptionpublic static long copy(ReadableByteChannel inputChannel, WritableByteChannel outputChannel) throws IOException
ReadableByteChannel to a WritableByteChannel.
Note: The ReadableByteChannel and WritableByteChannels are NOT closed by the method
IOExceptionpublic static void tar(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path sourcePath,
org.apache.hadoop.fs.Path destPath)
throws IOException
Path as input and a given Path as a destination. If the given
input is a file then only that file will be added to tarball. If it is a directory then the entire directory will
be recursively put into the tarball.fs - the FileSystem the input exists, and the the output should be written to.sourcePath - the Path of the input files, this can either be a file or a directory.destPath - the Path that tarball should be written to.IOExceptionpublic static void tar(org.apache.hadoop.fs.FileSystem sourceFs,
org.apache.hadoop.fs.FileSystem destFs,
org.apache.hadoop.fs.Path sourcePath,
org.apache.hadoop.fs.Path destPath)
throws IOException
tar(FileSystem, Path, Path) except the source and destination FileSystem can be different.IOExceptiontar(FileSystem, Path, Path)public static boolean isCompressed(byte[] bytes)
public static void byteBufferToOutputStream(ByteBuffer in, OutputStream out) throws IOException
in - ByteBuffer to write into the OutputStreamout - Destination streamIOException - If there is an error writing into the OutputStream