# Text

public class **Text** extends [Object](https://developer.android.com/reference/java/lang/Object.html)  
A hierarchical representation of texts.

A `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text` contains a list
of `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock`,
and a `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock`
contains a list of `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Line` which
is composed of a list of `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Element`.

### Nested Class Summary

|---|---|---|---|
| class | [Text.Element](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Element) || Represents a space-separated segment in a line of text (for example, a word in most Latin languages). |
| class | [Text.Line](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Line) || Represents a line of text. |
| class | [Text.Symbol](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Symbol) || Represents a single symbol in an `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Element`. |
| class | [Text.TextBlock](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock) || A block of text (think of it as a paragraph) as deemed by the OCR engine. |

### Public Method Summary

|---|---|
| [String](https://developer.android.com/reference/java/lang/String.html) | [getText](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text#getText())() Retrieves all the recognized text in the image. |
| [List](https://developer.android.com/reference/java/util/List.html)\<[Text.TextBlock](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock)\> | [getTextBlocks](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text#getTextBlocks())() Gets an unmodifiable list of `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock`, which is a block of text and can be further decomposed to a list of `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Line`. |

### Inherited Method Summary

From class java.lang.Object

|---|---|
| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| void | finalize() |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public [String](https://developer.android.com/reference/java/lang/String.html) **getText** ()

Retrieves all the recognized text in the image. It concatenates text strings from
underlying `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock`s
separated by `'\n'`.

Returns an empty string if nothing is found.

#### public [List](https://developer.android.com/reference/java/util/List.html)\<[Text.TextBlock](https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock)\>
**getTextBlocks** ()

Gets an unmodifiable list of `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock`,
which is a block of text and can be further decomposed to a list of `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Line`.

The recognized text is in reading order for the language. For Latin, this is top to
bottom within a `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.TextBlock`,
and left-to-right within a `https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Line`.

Returns an empty list if nothing is found.