Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Fields](https://developer.android.com/reference/java/nio/charset/CoderResult#lfields) \| [Methods](https://developer.android.com/reference/java/nio/charset/CoderResult#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/nio/charset/CoderResult#inhmethods)

# CoderResult


`
public


class
CoderResult
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.nio.charset.CoderResult |

<br />

*** ** * ** ***

A description of the result state of a coder.

A charset coder, that is, either a decoder or an encoder, consumes bytes
(or characters) from an input buffer, translates them, and writes the
resulting characters (or bytes) to an output buffer. A coding process
terminates for one of four categories of reasons, which are described by
instances of this class:

- *Underflow* is reported when there is no more input to be
  processed, or there is insufficient input and additional input is
  required. This condition is represented by the unique result object
  `https://developer.android.com/reference/java/nio/charset/CoderResult#UNDERFLOW`, whose `https://developer.android.com/reference/java/nio/charset/CoderResult#isUnderflow()` method
  returns `true`.

- *Overflow* is reported when there is insufficient room
  remaining in the output buffer. This condition is represented by the
  unique result object `https://developer.android.com/reference/java/nio/charset/CoderResult#OVERFLOW`, whose `https://developer.android.com/reference/java/nio/charset/CoderResult#isOverflow()` method returns `true`.

- A *malformed-input error* is reported when a sequence of
  input units is not well-formed. Such errors are described by instances of
  this class whose `https://developer.android.com/reference/java/nio/charset/CoderResult#isMalformed()` method returns
  `true` and whose `https://developer.android.com/reference/java/nio/charset/CoderResult#length()` method returns the length
  of the malformed sequence. There is one unique instance of this class for
  all malformed-input errors of a given length.

- An *unmappable-character error* is reported when a sequence
  of input units denotes a character that cannot be represented in the
  output charset. Such errors are described by instances of this class
  whose `https://developer.android.com/reference/java/nio/charset/CoderResult#isUnmappable()` method returns `true` and
  whose `https://developer.android.com/reference/java/nio/charset/CoderResult#length()` method returns the length of the input
  sequence denoting the unmappable character. There is one unique instance
  of this class for all unmappable-character errors of a given length.

For convenience, the `https://developer.android.com/reference/java/nio/charset/CoderResult#isError()` method returns `true`
for result objects that describe malformed-input and unmappable-character
errors but `false` for those that describe underflow or overflow
conditions.

<br />

## Summary

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/java/nio/charset/CoderResult` | `https://developer.android.com/reference/java/nio/charset/CoderResult#OVERFLOW` Result object indicating overflow, meaning that there is insufficient room in the output buffer. |
| ` public static final https://developer.android.com/reference/java/nio/charset/CoderResult` | `https://developer.android.com/reference/java/nio/charset/CoderResult#UNDERFLOW` Result object indicating underflow, meaning that either the input buffer has been completely consumed or, if the input buffer is not yet empty, that additional input is required. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#isError()() ` Tells whether or not this object describes an error condition. |
| ` boolean` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#isMalformed()() ` Tells whether or not this object describes a malformed-input error. |
| ` boolean` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#isOverflow()() ` Tells whether or not this object describes an overflow condition. |
| ` boolean` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#isUnderflow()() ` Tells whether or not this object describes an underflow condition. |
| ` boolean` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#isUnmappable()() ` Tells whether or not this object describes an unmappable-character error. |
| ` int` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#length()() ` Returns the length of the erroneous input described by this object *(optional operation)*. |
| ` static https://developer.android.com/reference/java/nio/charset/CoderResult` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#malformedForLength(int)(int length) ` Static factory method that returns the unique object describing a malformed-input error of the given length. |
| ` void` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#throwException()() ` Throws an exception appropriate to the result described by this object. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#toString()() ` Returns a string describing this coder result. |
| ` static https://developer.android.com/reference/java/nio/charset/CoderResult` | ` https://developer.android.com/reference/java/nio/charset/CoderResult#unmappableForLength(int)(int length) ` Static factory method that returns the unique result object describing an unmappable-character error of the given length. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Fields

### OVERFLOW

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final CoderResult OVERFLOW
```

Result object indicating overflow, meaning that there is insufficient
room in the output buffer.

<br />

### UNDERFLOW

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final CoderResult UNDERFLOW
```

Result object indicating underflow, meaning that either the input buffer
has been completely consumed or, if the input buffer is not yet empty,
that additional input is required.

<br />

## Public methods

### isError

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isError ()
```

Tells whether or not this object describes an error condition.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if, and only if, this object denotes either a malformed-input error or an unmappable-character error <br /> |

### isMalformed

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isMalformed ()
```

Tells whether or not this object describes a malformed-input error.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if, and only if, this object denotes a malformed-input error <br /> |

### isOverflow

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isOverflow ()
```

Tells whether or not this object describes an overflow condition.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if, and only if, this object denotes overflow <br /> |

### isUnderflow

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isUnderflow ()
```

Tells whether or not this object describes an underflow condition.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if, and only if, this object denotes underflow <br /> |

### isUnmappable

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isUnmappable ()
```

Tells whether or not this object describes an unmappable-character
error.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if, and only if, this object denotes an unmappable-character error <br /> |

### length

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int length ()
```

Returns the length of the erroneous input described by this
object *(optional operation)*.

<br />

| Returns ||
|---|---|
| `int` | The length of the erroneous input, a positive integer <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If this object does not describe an error condition, that is, if the `https://developer.android.com/reference/java/nio/charset/CoderResult#isError()` does not return `true` |

### malformedForLength

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static CoderResult malformedForLength (int length)
```

Static factory method that returns the unique object describing a
malformed-input error of the given length.

<br />

| Parameters ||
|---|---|
| `length` | `int`: The given length <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/charset/CoderResult` | The requested coder-result object <br /> |

### throwException

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void throwException ()
```

Throws an exception appropriate to the result described by this object.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/nio/BufferOverflowException` | If this object is `https://developer.android.com/reference/java/nio/charset/CoderResult#OVERFLOW` |
| `https://developer.android.com/reference/java/nio/BufferUnderflowException` | If this object is `https://developer.android.com/reference/java/nio/charset/CoderResult#UNDERFLOW` |
| `https://developer.android.com/reference/java/nio/charset/MalformedInputException` | If this object represents a malformed-input error; the exception's length value will be that of this object |
| `https://developer.android.com/reference/java/nio/charset/UnmappableCharacterException` | If this object represents an unmappable-character error; the exceptions length value will be that of this object |
| `https://developer.android.com/reference/java/nio/charset/CharacterCodingException` |   |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string describing this coder result.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | A descriptive string <br /> |

### unmappableForLength

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static CoderResult unmappableForLength (int length)
```

Static factory method that returns the unique result object describing
an unmappable-character error of the given length.

<br />

| Parameters ||
|---|---|
| `length` | `int`: The given length <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/charset/CoderResult` | The requested coder-result object <br /> |