public class IOUtils
Utilities for I/O streams.
Static Methods
<S>deserialize(byte[] bytes)
public static S <S>deserialize(byte[] bytes)
Deserializes the given byte array into to a newly allocated object.
Name | Description |
bytes | byte[] byte array to deserialize or |
Type | Description |
S | new allocated object or |
Type | Description |
IOException |
<S>deserialize(InputStream inputStream)
public static S <S>deserialize(InputStream inputStream)
Deserializes the given input stream into to a newly allocated object, and close the input stream.
Name | Description |
inputStream | InputStream input stream to deserialize |
Type | Description |
S |
Type | Description |
IOException |
computeLength(StreamingContent content)
public 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.
Name | Description |
content | StreamingContent streaming content |
Type | Description |
long |
Type | Description |
IOException |
copy(InputStream inputStream, OutputStream outputStream) (deprecated)
public static void copy(InputStream inputStream, OutputStream outputStream)
Deprecated. use com.google.common.io.ByteStreams#copy(InputStream, OutputStream)
Writes the content provided by the given source input stream into the given destination output stream.
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(); } }
Name | Description |
inputStream | InputStream source input stream |
outputStream | OutputStream destination output stream |
Type | Description |
IOException |
copy(InputStream inputStream, OutputStream outputStream, boolean closeInputStream) (deprecated)
public static void copy(InputStream inputStream, OutputStream outputStream, boolean closeInputStream)
Deprecated. use com.google.common.io.ByteStreams#copy(InputStream, OutputStream)
Writes the content provided by the given source input stream into the given destination output stream, optionally closing the input stream.
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(); } }
Name | Description |
inputStream | InputStream source input stream |
outputStream | OutputStream destination output stream |
closeInputStream | boolean whether the input stream should be closed at the end of this method |
Type | Description |
IOException |
isSymbolicLink(File file) (deprecated)
public static boolean isSymbolicLink(File file)
Deprecated. use java.nio.file.Path#isSymbolicLink
Returns whether the given file is a symbolic link.
Name | Description |
file | File |
Type | Description |
boolean |
Type | Description |
IOException |
serialize(Object value)
public static byte[] serialize(Object value)
Serializes the given object value to a newly allocated byte array.
Name | Description |
value | Object object value to serialize |
Type | Description |
byte[] |
Type | Description |
IOException |
serialize(Object value, OutputStream outputStream)
public static void serialize(Object value, OutputStream outputStream)
Serializes the given object value to an output stream, and close the output stream.
Name | Description |
value | Object object value to serialize |
outputStream | OutputStream output stream to serialize into |
Type | Description |
IOException |
Constructors
IOUtils()
public IOUtils()