> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdp.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ResponseBodyReader

> A custom Reader that wraps the Reader from the OkHttp Response and ensures that the OkHttp Response object is properly closed when the reader is closed.

Package: [`com.coinbase.cdp.core`](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/core/index)

```java theme={null}
public class ResponseBodyReader extends FilterReader
```

A custom Reader that wraps the Reader from the OkHttp Response and ensures that the OkHttp Response object is properly closed when the reader is closed. This class extends FilterReader and takes an OkHttp Response object as a parameter. It retrieves the Reader from the Response and overrides the close method to close both the Reader and the Response object, ensuring proper resource management and preventing premature closure of the underlying HTTP connection.

## Constructor Details

### `ResponseBodyReader`

```java theme={null}
public ResponseBodyReader(okhttp3.Response response) throws IOException
```

Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object.

**Parameters:**

`response` (`okhttp3.Response`) - the OkHttp Response object from which the Reader is retrieved

**Throws:**

`[IOException](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/IOException.html "class or interface in java.io")` - if an I/O error occurs while retrieving the Reader

## Method Details

### `close`

```java theme={null}
public void close() throws IOException
```

Closes the Reader and the associated OkHttp Response object. This ensures that the underlying HTTP connection is properly closed after the reader is no longer needed.

**Specified by:**

`[close](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/AutoCloseable.html#close\(\) "class or interface in java.lang")` in interface `[AutoCloseable](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/AutoCloseable.html "class or interface in java.lang")`

**Specified by:**

`[close](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Closeable.html#close\(\) "class or interface in java.io")` in interface `[Closeable](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Closeable.html "class or interface in java.io")`

**Overrides:**

`[close](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/FilterReader.html#close\(\) "class or interface in java.io")` in class `[FilterReader](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/FilterReader.html "class or interface in java.io")`

**Throws:**

`[IOException](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/IOException.html "class or interface in java.io")` - if an I/O error occurs

**Returns:**

`void`
