|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.enterprise.adaptor.IOHelper
public class IOHelper
Utility class for providing useful methods when handling streams or other forms of I/O.
Method Summary | |
---|---|
static void |
copyStream(InputStream in,
OutputStream out)
Copy contents of in to out . |
static int |
readFully(InputStream is,
byte[] bytes,
int off,
int len)
Reads a specified number of bytes from a stream. |
static byte[] |
readInputStreamToByteArray(InputStream is)
Read the contents of is into a byte array. |
static String |
readInputStreamToString(InputStream is,
Charset charset)
Form a string from the contents of is with charset charset . |
static File |
writeToTempFile(InputStream in)
Write contents of in to a temporary file. |
static File |
writeToTempFile(String string,
Charset charset)
Write contents of string to a temporary file, encoded using charset . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void copyStream(InputStream in, OutputStream out) throws IOException
in
to out
.
IOException
public static byte[] readInputStreamToByteArray(InputStream is) throws IOException
is
into a byte array.
IOException
public static String readInputStreamToString(InputStream is, Charset charset) throws IOException
is
with charset charset
.
IOException
public static File writeToTempFile(InputStream in) throws IOException
in
to a temporary file. Caller is responsible for
deleting the temporary file after use.
IOException
public static File writeToTempFile(String string, Charset charset) throws IOException
string
to a temporary file, encoded using charset
. Caller is responsible for deleting the temporary file after use.
IOException
public static int readFully(InputStream is, byte[] bytes, int off, int len) throws IOException
is
- the stream from which the bytes will be read.bytes
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the number of bytes to read unless end of
stream is encountered
-1
if there is no more data because the end of
the stream has been reached.
IOException
- If the first byte cannot be read for any reason
other than reaching end-of-stream, or if the input stream
has been closed, or if some other I/O error occurs.
NullPointerException
- If b
is null
.
IndexOutOfBoundsException
- If off
is negative,
len
is negative, or len
is
greater than b.length - off
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |