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

# CharsetProvider

` public abstract class CharsetProvider `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

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

<br />

*** ** * ** ***

Charset service-provider class.

A charset provider is a concrete subclass of this class that has a zero-argument constructor and some number of associated charset implementation classes. Charset providers may be installed in an instance of the Java platform as extensions. Providers may also be made available by adding them to the applet or application class path or by some other platform-specific means. Charset providers are looked up via the current thread's `https://developer.android.com/reference/java/lang/Thread#getContextClassLoader()`.

A charset provider identifies itself with a provider-configuration file named `java.nio.charset.spi.CharsetProvider` in the resource directory `META-INF/services`. The file should contain a list of fully-qualified concrete charset-provider class names, one per line. A line is terminated by any one of a line feed (`'\n'`), a carriage return (`'\r'`), or a carriage return followed immediately by a line feed. Space and tab characters surrounding each name, as well as blank lines, are ignored. The comment character is `'#'` (`'\u0023'`); on each line all characters following the first comment character are ignored. The file must be encoded in UTF-8.

If a particular concrete charset provider class is named in more than one configuration file, or is named in the same configuration file more than once, then the duplicates will be ignored. The configuration file naming a particular provider need not be in the same jar file or other distribution unit as the provider itself. The provider must be accessible from the same class loader that was initially queried to locate the configuration file; this is not necessarily the class loader that loaded the file.

<br />

**See also:**

- `https://developer.android.com/reference/java/nio/charset/Charset`

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/nio/charset/spi/CharsetProvider#CharsetProvider()() ` Initializes a new charset provider. |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/nio/charset/Charset` | ` https://developer.android.com/reference/java/nio/charset/spi/CharsetProvider#charsetForName(java.lang.String)(https://developer.android.com/reference/java/lang/String charsetName) ` Retrieves a charset for the given charset name. |
| ` abstract https://developer.android.com/reference/java/util/Iterator<https://developer.android.com/reference/java/nio/charset/Charset>` | ` https://developer.android.com/reference/java/nio/charset/spi/CharsetProvider#charsets()() ` Creates an iterator that iterates over the charsets supported by this provider. |

### 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*.

## Protected constructors

### CharsetProvider

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

```
protected CharsetProvider ()
```

Initializes a new charset provider.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager has been installed and it denies `https://developer.android.com/reference/java/lang/RuntimePermission``("charsetProvider")` |

## Public methods

### charsetForName

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

```
public abstract Charset charsetForName (String charsetName)
```

Retrieves a charset for the given charset name.

<br />

| Parameters ||
|---|---|
| `charsetName` | `String`: The name of the requested charset; may be either a canonical name or an alias <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/charset/Charset` | A charset object for the named charset, or `null` if the named charset is not supported by this provider <br /> |

### charsets

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

```
public abstract Iterator<Charset> charsets ()
```

Creates an iterator that iterates over the charsets supported by this provider. This method is used in the implementation of the `https://developer.android.com/reference/java/nio/charset/Charset#availableCharsets()` method.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Iterator<https://developer.android.com/reference/java/nio/charset/Charset>` | The new iterator <br /> |