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

    public class ProtocolBuffers

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

Utilities for protocol buffers.

There is no official media type for protocol buffers registered with the [IANA](http://www.iana.org/assignments/media-types/application/index.html). [#CONTENT_TYPE](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.protobuf.ProtocolBuffers#com_google_api_client_protobuf_ProtocolBuffers_CONTENT_TYPE) and [#ALT_CONTENT_TYPE](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.protobuf.ProtocolBuffers#com_google_api_client_protobuf_ProtocolBuffers_ALT_CONTENT_TYPE) are some of the more popular choices being used
today, but other media types are also in use.

## Inheritance

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

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

### ALT_CONTENT_TYPE

    public static final String ALT_CONTENT_TYPE

`"application/x-protobuffer"` content type.

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

### CONTENT_TYPE

    public static final String CONTENT_TYPE

`"application/x-protobuf"` content type.

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

## Static Methods

### \<T\>parseAndClose(InputStream inputStream, Class\<T\> messageClass)

    public static T <T>parseAndClose(InputStream inputStream, Class<T> messageClass)

Parses protocol buffer content from an input stream (closing the input stream) into a protocol
buffer message.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `inputStream` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` |
| `messageClass` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<T>` destination message class that has a `parseFrom(InputStream)` public static method |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` | new instance of the parsed destination message class |

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