# Class TextFormat.Printer (3.19.4)

    public static final class TextFormat.Printer

Helper class for converting protobufs to text.

## Inheritance

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

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

## Methods

### escapingNonAscii(boolean escapeNonAscii)

    public TextFormat.Printer escapingNonAscii(boolean escapeNonAscii)

Return a new Printer instance with the specified escape mode.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `escapeNonAscii` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` If true, the new Printer will escape non-ASCII characters (this is the default behavior. If false, the new Printer will print non-ASCII characters as is. In either case, the new Printer still escapes newlines and quotes in strings. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.TextFormat.Printer` | a new Printer that clones all other configurations from the current Printer, with the escape mode set to the given parameter. |

### print(MessageOrBuilder message, Appendable output)

    public void print(MessageOrBuilder message, Appendable output)

Outputs a textual representation of the Protocol Message supplied into the parameter output.
(This representation is the new version of the classic "ProtocolPrinter" output from the
original Protocol Buffer system)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `message` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder` |
| `output` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Appendable.html` |

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

### print(UnknownFieldSet fields, Appendable output)

    public void print(UnknownFieldSet fields, Appendable output)

Outputs a textual representation of `fields` to `output`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `fields` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |
| `output` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Appendable.html` |

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

### printField(Descriptors.FieldDescriptor field, Object value, Appendable output)

    public void printField(Descriptors.FieldDescriptor field, Object value, Appendable output)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FieldDescriptor` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |
| `output` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Appendable.html` |

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

### printFieldToString(Descriptors.FieldDescriptor field, Object value)

    public String printFieldToString(Descriptors.FieldDescriptor field, Object value)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FieldDescriptor` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

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

### printFieldValue(Descriptors.FieldDescriptor field, Object value, Appendable output)

    public void printFieldValue(Descriptors.FieldDescriptor field, Object value, Appendable output)

Outputs a textual representation of the value of given field value.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FieldDescriptor` the descriptor of the field |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` the value of the field |
| `output` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Appendable.html` the output to which to append the formatted value |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | if the value is not appropriate for the given field descriptor |

### printToString(MessageOrBuilder message)

    public String printToString(MessageOrBuilder message)

Like `print()`, but writes directly to a `String` and returns it.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `message` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder` |

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

### printToString(UnknownFieldSet fields)

    public String printToString(UnknownFieldSet fields)

Like `print()`, but writes directly to a `String` and returns it.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `fields` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |

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

### shortDebugString(Descriptors.FieldDescriptor field, Object value)

    public String shortDebugString(Descriptors.FieldDescriptor field, Object value)

Generates a human readable form of the field, useful for debugging and other purposes, with
no newline characters.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FieldDescriptor` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

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

### shortDebugString(MessageOrBuilder message)

    public String shortDebugString(MessageOrBuilder message)

Generates a human readable form of this message, useful for debugging and other purposes,
with no newline characters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `message` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder` |

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

### shortDebugString(UnknownFieldSet fields)

    public String shortDebugString(UnknownFieldSet fields)

Generates a human readable form of the unknown fields, useful for debugging and other
purposes, with no newline characters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `fields` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |

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

### usingTypeRegistry(TypeRegistry typeRegistry)

    public TextFormat.Printer usingTypeRegistry(TypeRegistry typeRegistry)

Creates a new Printer using the given typeRegistry. The new Printer clones all other
configurations from the current Printer.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `typeRegistry` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.TypeRegistry` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.TextFormat.Printer` |   |