# Class AbstractInputStreamContent (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.http.AbstractInputStreamContent)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.http.AbstractInputStreamContent)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.AbstractInputStreamContent)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.AbstractInputStreamContent)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.AbstractInputStreamContent)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.AbstractInputStreamContent)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.AbstractInputStreamContent)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.AbstractInputStreamContent)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.AbstractInputStreamContent)

    public abstract class AbstractInputStreamContent implements HttpContent

Serializes HTTP request content from an input stream into an output stream.

The #type field is required. Subclasses should implement the #getLength(),
[#getInputStream()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractInputStreamContent#com_google_api_client_http_AbstractInputStreamContent_getInputStream__), and #retrySupported() for their specific type of input stream.
By default, all content is read from the input stream. If instead you want to limit the maximum
amount of content read from the input stream, you may use ByteStreams#limit(InputStream, long).

Implementations don't need to be thread-safe.

## Inheritance

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

## Implements

[HttpContent](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpContent)

## 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-)

## Constructors

### AbstractInputStreamContent(String type)

    public AbstractInputStreamContent(String type)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `type` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Content type or `null` for none |

## Methods

### getCloseInputStream()

    public final boolean getCloseInputStream()

Returns whether the input stream should be closed at the end of [#writeTo](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractInputStreamContent#com_google_api_client_http_AbstractInputStreamContent_writeTo_). Default is
`true`.

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

### getInputStream()

    public abstract InputStream getInputStream()

Return an input stream for the specific implementation type of [AbstractInputStreamContent](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractInputStreamContent). If the specific implementation will return `true` for #retrySupported() this should be a factory function which will create a new [InputStream](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html) from the source data whenever invoked.

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

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

### getType()

    public String getType()

Returns the content type or `null` for none.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### setCloseInputStream(boolean closeInputStream)

    public AbstractInputStreamContent setCloseInputStream(boolean closeInputStream)

Sets whether the input stream should be closed at the end of [#writeTo](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractInputStreamContent#com_google_api_client_http_AbstractInputStreamContent_writeTo_). Default is
`true`. Subclasses should override by calling super.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `closeInputStream` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractInputStreamContent` |   |

### setType(String type)

    public AbstractInputStreamContent setType(String type)

Sets the content type or `null` for none. Subclasses should override by calling super.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `type` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractInputStreamContent` |   |

### writeTo(OutputStream out)

    public void writeTo(OutputStream out)

Writes the byte content to the given output stream.

Implementations must not close the output stream, and instead should flush the output
stream. Some callers may assume that the output stream has not been closed, and will fail to
work if it has been closed.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `out` | `https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html` |

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