|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.io.IOUtils
@InterfaceAudience.Public @InterfaceStability.Evolving public class IOUtils
An utility class for I/O related functionality.
Nested Class Summary | |
---|---|
static class |
IOUtils.NullOutputStream
The /dev/null of OutputStreams. |
Constructor Summary | |
---|---|
IOUtils()
|
Method Summary | |
---|---|
static void |
cleanup(org.apache.commons.logging.Log log,
Closeable... closeables)
Close the Closeable objects and ignore any IOException or
null pointers. |
static void |
closeSocket(Socket sock)
Closes the socket ignoring IOException |
static void |
closeStream(Closeable stream)
Closes the stream ignoring IOException . |
static void |
copyBytes(InputStream in,
OutputStream out,
Configuration conf)
Copies from one stream to another. |
static void |
copyBytes(InputStream in,
OutputStream out,
Configuration conf,
boolean close)
Copies from one stream to another. |
static void |
copyBytes(InputStream in,
OutputStream out,
int buffSize)
Copies from one stream to another. |
static void |
copyBytes(InputStream in,
OutputStream out,
int buffSize,
boolean close)
Copies from one stream to another. |
static void |
copyBytes(InputStream in,
OutputStream out,
long count,
boolean close)
Copies count bytes from one stream to another. |
static void |
readFully(InputStream in,
byte[] buf,
int off,
int len)
Reads len bytes in a loop. |
static void |
skipFully(InputStream in,
long len)
Similar to readFully(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IOUtils()
Method Detail |
---|
public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException
in
- InputStrem to read fromout
- OutputStream to write tobuffSize
- the size of the bufferclose
- whether or not close the InputStream and
OutputStream at the end. The streams are closed in the finally clause.
IOException
public static void copyBytes(InputStream in, OutputStream out, int buffSize) throws IOException
in
- InputStrem to read fromout
- OutputStream to write tobuffSize
- the size of the buffer
IOException
public static void copyBytes(InputStream in, OutputStream out, Configuration conf) throws IOException
in
- InputStrem to read fromout
- OutputStream to write toconf
- the Configuration object
IOException
public static void copyBytes(InputStream in, OutputStream out, Configuration conf, boolean close) throws IOException
in
- InputStream to read fromout
- OutputStream to write toconf
- the Configuration objectclose
- whether or not close the InputStream and
OutputStream at the end. The streams are closed in the finally clause.
IOException
public static void copyBytes(InputStream in, OutputStream out, long count, boolean close) throws IOException
in
- InputStream to read fromout
- OutputStream to write tocount
- number of bytes to copyclose
- whether to close the streams
IOException
- if bytes can not be read or writtenpublic static void readFully(InputStream in, byte[] buf, int off, int len) throws IOException
in
- InputStream to read frombuf
- The buffer to filloff
- offset from the bufferlen
- the length of bytes to read
IOException
- if it could not read requested number of bytes
for any reason (including EOF)public static void skipFully(InputStream in, long len) throws IOException
in
- The InputStream to skip bytes fromlen
- number of bytes to skip.
IOException
- if it could not skip requested number of bytes
for any reason (including EOF)public static void cleanup(org.apache.commons.logging.Log log, Closeable... closeables)
IOException
or
null pointers. Must only be used for cleanup in exception handlers.
log
- the log to record problems to at debug level. Can be null.closeables
- the objects to closepublic static void closeStream(Closeable stream)
IOException
.
Must only be called in cleaning up from exception handlers.
stream
- the Stream to closepublic static void closeSocket(Socket sock)
IOException
sock
- the Socket to close
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |