# Class IOUtils (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.IOUtils)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.util.IOUtils)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.util.IOUtils)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.util.IOUtils)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.util.IOUtils)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.util.IOUtils)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.util.IOUtils)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.util.IOUtils)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.util.IOUtils)

    public class IOUtils

Utilities for I/O streams.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> IOUtils

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## 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` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[]` byte array to deserialize or `null` for `null` result |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `S` | new allocated object or `null` for `null` input |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### \<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` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` input stream to deserialize |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `S` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### 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)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.StreamingContent#com_google_api_client_util_StreamingContent_writeTo_java_io_OutputStream_) on a fake output stream that only counts bytes written.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `content` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.StreamingContent` streaming content |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### copy(InputStream inputStream, OutputStream outputStream) (deprecated)

    public static void copy(InputStream inputStream, OutputStream outputStream)

**Deprecated.** *use [com.google.common.io.ByteStreams#copy(InputStream, OutputStream)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.ByteStreams#com_google_api_client_util_ByteStreams_copy_)*

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` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` source input stream |
| `outputStream` | `https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html` destination output stream |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### 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)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.ByteStreams#com_google_api_client_util_ByteStreams_copy_)*

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` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` source input stream |
| `outputStream` | `https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html` destination output stream |
| `closeInputStream` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` whether the input stream should be closed at the end of this method |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### 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` | `https://docs.oracle.com/javase/8/docs/api/java/io/File.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### serialize(Object value)

    public static byte[] serialize(Object value)

Serializes the given object value to a newly allocated byte array.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` object value to serialize |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[]` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` object value to serialize |
| `outputStream` | `https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html` output stream to serialize into |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

## Constructors

### IOUtils()

    public IOUtils()