# StrokeInputBatchSerialization

Artifact: [androidx.ink:ink-storage](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/storage/StrokeInputBatchExtensions.jvmAndAndroid.kt+class:androidx.ink.storage.StrokeInputBatchSerialization) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- android

  ```
  object StrokeInputBatchSerialization
  ```

*** ** * ** ***

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#decode(kotlin.ByteArray)(input: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html)` Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#decode(java.io.InputStream)(input: https://developer.android.com/reference/java/io/InputStream.html)` Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#encode(androidx.ink.strokes.StrokeInputBatch)(strokeInputBatch: https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch)` Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` to a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#encode(androidx.ink.strokes.StrokeInputBatch,java.io.OutputStream)(strokeInputBatch: https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch, output: https://developer.android.com/reference/java/io/OutputStream.html)` Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` to the given `https://developer.android.com/reference/java/io/OutputStream.html`. | android |

## Public functions

### decode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun decode(input: ByteArray): ImmutableStrokeInputBatch
```

Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful. Kotlin callers should use `https://developer.android.com/reference/kotlin/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(java.io.InputStream)` instead.

| Parameters |
|---|---|
| `input: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` providing gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto messages, the same as written to `https://developer.android.com/reference/java/io/OutputStream.html` by `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#encode(androidx.ink.strokes.StrokeInputBatch,java.io.OutputStream)`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` | The `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` parsed from the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#decode(kotlin.ByteArray)` does not provide a valid `ink.proto.CodedStrokeInputBatch` proto message, or the corresponding `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` is invalid. |

### decode

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
fun decode(input: InputStream): ImmutableStrokeInputBatch
```

Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful. Kotlin callers should use `https://developer.android.com/reference/kotlin/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(java.io.InputStream)` instead.

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/java/io/InputStream.html` | `https://developer.android.com/reference/java/io/InputStream.html` providing gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto messages, the same as written to `https://developer.android.com/reference/java/io/OutputStream.html` by `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#encode(androidx.ink.strokes.StrokeInputBatch,java.io.OutputStream)`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` | The `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` parsed from the `https://developer.android.com/reference/java/io/InputStream.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | if gzip-format bytes cannot be read from `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#decode(java.io.InputStream)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/StrokeInputBatchSerialization#decode(java.io.InputStream)` does not provide a valid `ink.proto.CodedStrokeInputBatch` proto message, or the corresponding `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` is invalid. |

### encode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
fun encode(strokeInputBatch: StrokeInputBatch): ByteArray
```

Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` to a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. Kotlin callers should use `https://developer.android.com/reference/kotlin/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch).encode(java.io.OutputStream)` instead.

### encode

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
fun encode(strokeInputBatch: StrokeInputBatch, output: OutputStream): Unit
```

Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` to the given `https://developer.android.com/reference/java/io/OutputStream.html`. Kotlin callers should use `https://developer.android.com/reference/kotlin/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch).encode(java.io.OutputStream)` instead.