public class IOUtilsUtilities 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.
| Parameter | |
|---|---|
| Name | Description |
bytes |
byte[]byte array to deserialize or |
| Returns | |
|---|---|
| Type | Description |
S |
new allocated object or |
| Exceptions | |
|---|---|
| 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.
| Parameter | |
|---|---|
| Name | Description |
inputStream |
InputStreaminput stream to deserialize |
| Returns | |
|---|---|
| Type | Description |
S |
|
| Exceptions | |
|---|---|
| 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.
| Parameter | |
|---|---|
| Name | Description |
content |
StreamingContentstreaming content |
| Returns | |
|---|---|
| Type | Description |
long |
|
| Exceptions | |
|---|---|
| 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(); } }
| Parameters | |
|---|---|
| Name | Description |
inputStream |
InputStreamsource input stream |
outputStream |
OutputStreamdestination output stream |
| Exceptions | |
|---|---|
| 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(); } }
| Parameters | |
|---|---|
| Name | Description |
inputStream |
InputStreamsource input stream |
outputStream |
OutputStreamdestination output stream |
closeInputStream |
booleanwhether the input stream should be closed at the end of this method |
| Exceptions | |
|---|---|
| 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.
| Parameter | |
|---|---|
| Name | Description |
file |
File |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
serialize(Object value)
public static byte[] serialize(Object value)Serializes the given object value to a newly allocated byte array.
| Parameter | |
|---|---|
| Name | Description |
value |
Objectobject value to serialize |
| Returns | |
|---|---|
| Type | Description |
byte[] |
|
| Exceptions | |
|---|---|
| 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.
| Parameters | |
|---|---|
| Name | Description |
value |
Objectobject value to serialize |
outputStream |
OutputStreamoutput stream to serialize into |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
Constructors
IOUtils()
public IOUtils()