public class IOUtils extends 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(InputStream inputStream,
OutputStream outputStream)
Deprecated.
use
ByteStreams.copy(InputStream, OutputStream) |
static void |
copy(InputStream inputStream,
OutputStream outputStream,
boolean closeInputStream)
Deprecated.
use
ByteStreams.copy(InputStream, OutputStream) |
static <S extends Serializable> |
deserialize(byte[] bytes)
Deserializes the given byte array into to a newly allocated object.
|
static <S extends Serializable> |
deserialize(InputStream inputStream)
Deserializes the given input stream into to a newly allocated object, and close the input
stream.
|
static boolean |
isSymbolicLink(File file)
Deprecated.
use java.nio.file.Path#isSymbolicLink
|
static byte[] |
serialize(Object value)
Serializes the given object value to a newly allocated byte array.
|
static void |
serialize(Object value,
OutputStream outputStream)
Serializes the given object value to an output stream, and close the output stream.
|
@Deprecated public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException
ByteStreams.copy(InputStream, OutputStream)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 streamIOException@Deprecated public static void copy(InputStream inputStream, OutputStream outputStream, boolean closeInputStream) throws IOException
ByteStreams.copy(InputStream, OutputStream)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 methodIOExceptionpublic static long computeLength(StreamingContent content) throws IOException
StreamingContent.writeTo(OutputStream) on a fake output stream that only counts bytes written.content - streaming contentIOExceptionpublic static byte[] serialize(Object value) throws IOException
value - object value to serializeIOExceptionpublic static void serialize(Object value, OutputStream outputStream) throws IOException
value - object value to serializeoutputStream - output stream to serialize intoIOExceptionpublic static <S extends Serializable> S deserialize(byte[] bytes) throws IOException
bytes - byte array to deserialize or null for null resultnull for null inputIOExceptionpublic static <S extends Serializable> S deserialize(InputStream inputStream) throws IOException
inputStream - input stream to deserializeIOException@Deprecated public static boolean isSymbolicLink(File file) throws IOException
IOExceptionCopyright © 2011–2025 Google. All rights reserved.