Stay organized with collections
Save and categorize content based on your preferences.
CharsetProvider
abstract class CharsetProvider
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 context class
.
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.
Summary
Protected constructors |
Initializes a new charset provider.
|
Public methods |
abstract Charset! |
Retrieves a charset for the given charset name.
|
abstract MutableIterator<Charset!>! |
Creates an iterator that iterates over the charsets supported by this provider.
|
Protected constructors
CharsetProvider
protected CharsetProvider()
Initializes a new charset provider.
Exceptions |
java.lang.SecurityException |
If a security manager has been installed and it denies RuntimePermission ("charsetProvider") |
Public methods
charsetForName
abstract fun charsetForName(charsetName: String!): Charset!
Retrieves a charset for the given charset name.
Parameters |
charsetName |
String!: The name of the requested charset; may be either a canonical name or an alias |
Return |
Charset! |
A charset object for the named charset, or null if the named charset is not supported by this provider |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# CharsetProvider\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nCharsetProvider\n===============\n\n```\nabstract class CharsetProvider\n```\n\n|---|-------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [java.nio.charset.spi.CharsetProvider](#) |\n\nCharset service-provider class.\n\nA 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 [context class](../../../lang/Thread.html#getContextClassLoader()).\n\nA 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.\n\nIf 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.\n\nSummary\n-------\n\n| Protected constructors ||\n|-------------------------------------------------------------------------------|---|\n| [CharsetProvider](#CharsetProvider())`()` Initializes a new charset provider. |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Charset](../Charset.html#)! | [charsetForName](#charsetForName(kotlin.String))`(`charsetName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Retrieves a charset for the given charset name. |\n| abstract [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)\\\u003c[Charset](../Charset.html#)!\\\u003e! | [charsets](#charsets())`()` Creates an iterator that iterates over the charsets supported by this provider. |\n\nProtected constructors\n----------------------\n\n### CharsetProvider\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nprotected CharsetProvider()\n```\n\nInitializes a new charset provider.\n\n| Exceptions ||\n|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| `java.lang.SecurityException` | If a security manager has been installed and it denies [RuntimePermission](../../../lang/RuntimePermission.html#)`(\"charsetProvider\")` |\n\nPublic methods\n--------------\n\n### charsetForName\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun charsetForName(charsetName: String!): Charset!\n```\n\nRetrieves a charset for the given charset name.\n\n| Parameters ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `charsetName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The name of the requested charset; may be either a canonical name or an alias |\n\n| Return ||\n|------------------------------|----------------------------------------------------------------------------------------------------------|\n| [Charset](../Charset.html#)! | A charset object for the named charset, or `null` if the named charset is not supported by this provider |\n\n### charsets\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun charsets(): MutableIterator\u003cCharset!\u003e!\n```\n\nCreates an iterator that iterates over the charsets supported by this provider. This method is used in the implementation of the [Charset.availableCharsets](../Charset.html#availableCharsets()) method.\n\n| Return ||\n|------------------------------------------------------------------------------------------------------------------------------------------------|------------------|\n| [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)\u003c[Charset](../Charset.html#)!\u003e! | The new iterator |"]]