public class IOUtils
extends java.lang.Object
| Constructor and Description |
|---|
IOUtils() |
| Modifier and Type | Method and Description |
|---|---|
static long |
computeLength(StreamingContent content)
Computes and returns the byte content length for a streaming content by calling
StreamingContent.writeTo(OutputStream) on a fake output stream that only counts bytes
written. |
static void |
copy(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Writes the content provided by the given source input stream into the given destination output
stream.
|
static void |
copy(java.io.InputStream inputStream,
java.io.OutputStream outputStream,
boolean closeInputStream)
Writes the content provided by the given source input stream into the given destination output
stream, optionally closing the input stream.
|
static <S extends java.io.Serializable> |
deserialize(byte[] bytes)
Deserializes the given byte array into to a newly allocated object.
|
static <S extends java.io.Serializable> |
deserialize(java.io.InputStream inputStream)
Deserializes the given input stream into to a newly allocated object, and close the input
stream.
|
static boolean |
isSymbolicLink(java.io.File file)
Returns whether the given file is a symbolic link.
|
static byte[] |
serialize(java.lang.Object value)
Serializes the given object value to a newly allocated byte array.
|
static void |
serialize(java.lang.Object value,
java.io.OutputStream outputStream)
Serializes the given object value to an output stream, and close the output stream.
|
public static void copy(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
throws java.io.IOException
The input stream is guaranteed to be closed at the end of this method.
Sample use:
static void copy(InputStream inputStream, File file) throws IOException {
FileOutputStream out = new FileOutputStream(file);
try {
IOUtils.copy(inputStream, out);
} finally {
out.close();
}
}
inputStream - source input streamoutputStream - destination output streamjava.io.IOExceptionpublic static void copy(java.io.InputStream inputStream,
java.io.OutputStream outputStream,
boolean closeInputStream)
throws java.io.IOException
Sample use:
static void copy(InputStream inputStream, File file) throws IOException {
FileOutputStream out = new FileOutputStream(file);
try {
IOUtils.copy(inputStream, out, true);
} finally {
out.close();
}
}
inputStream - source input streamoutputStream - destination output streamcloseInputStream - whether the input stream should be closed at the end of this methodjava.io.IOExceptionpublic static long computeLength(StreamingContent content) throws java.io.IOException
StreamingContent.writeTo(OutputStream) on a fake output stream that only counts bytes
written.content - streaming contentjava.io.IOExceptionpublic static byte[] serialize(java.lang.Object value)
throws java.io.IOException
value - object value to serializejava.io.IOExceptionpublic static void serialize(java.lang.Object value,
java.io.OutputStream outputStream)
throws java.io.IOException
value - object value to serializeoutputStream - output stream to serialize intojava.io.IOExceptionpublic static <S extends java.io.Serializable> S deserialize(byte[] bytes)
throws java.io.IOException
bytes - byte array to deserialize or null for null resultnull for null inputjava.io.IOExceptionpublic static <S extends java.io.Serializable> S deserialize(java.io.InputStream inputStream)
throws java.io.IOException
inputStream - input stream to deserializejava.io.IOExceptionpublic static boolean isSymbolicLink(java.io.File file)
throws java.io.IOException
java.io.IOExceptionCopyright © 2011-2018 Google. All Rights Reserved.