# Uses of Class
java.nio.charset.Charset

Packages that use Charset
Package
Description
com.sun.net.httpserver
Provides a simple high-level Http server API, which can be used to build embedded HTTP servers.
java.io
Provides for system input and output through data streams, serialization and the file system.
java.lang
Provides classes that are fundamental to the design of the Java programming language.
java.lang.foreign
Provides low-level access to memory and functions outside the Java runtime.
java.net
Provides the classes for implementing networking applications.
java.net.http
HTTP Client and WebSocket APIs
java.nio.channels
Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.
java.nio.charset
Defines charsets, decoders, and encoders, for translating between bytes and Unicode characters.
java.nio.charset.spi
Service-provider classes for the `java.nio.charset` package.
java.nio.file
Defines interfaces and classes for the Java virtual machine to access files, file attributes, and file systems.
java.util
Contains the collections framework, some internationalization support classes, a service loader, properties, random number generation, string parsing and scanning classes, base64 encoding and decoding, a bit array, and several miscellaneous utility classes.
java.util.zip
Provides classes for reading and writing the standard ZIP and GZIP file formats.
javax.tools
Provides interfaces for tools which can be invoked from a program, for example, compilers.
jdk.jshell
Provides interfaces for creating tools, such as a Read-Eval-Print Loop (REPL), which interactively evaluate "snippets" of Java programming language code.

- ## Uses of Charset in com.sun.net.httpserver

  Constructors in com.sun.net.httpserver with parameters of type Charset
  Modifier
  Constructor
  Description
  ``
  `BasicAuthenticator(String realm, Charset charset)`
  Creates a `BasicAuthenticator` for the given HTTP realm and using the given `Charset` to decode the Basic authentication credentials (username and password).

- ## Uses of Charset in java.io

  Methods in java.io that return Charset
  Modifier and Type
  Method
  Description
  `Charset`
  Console.`charset()`
  Returns the `Charset` object used for the write operations on this `Console`.
  `Charset`
  PrintStream.`charset()`
  Returns the charset used in this `PrintStream` instance.
  Methods in java.io with parameters of type Charset
  Modifier and Type
  Method
  Description
  `String`
  ByteArrayOutputStream.`toString(Charset charset)`
  Converts the buffer's contents into a string by decoding the bytes using the specified `charset`.
  Constructors in java.io with parameters of type Charset
  Modifier
  Constructor
  Description
  ``
  `FileReader(File file, Charset charset)`
  Creates a new `FileReader`, given the `File` to read and the charset.
  ``
  `FileReader(String fileName, Charset charset)`
  Creates a new `FileReader`, given the name of the file to read and the charset.
  ``
  `FileWriter(File file, Charset charset)`
  Constructs a `FileWriter` given the `File` to write and charset.
  ``
  `FileWriter(File file, Charset charset, boolean append)`
  Constructs a `FileWriter` given the `File` to write, charset and a boolean indicating whether to append the data written.
  ``
  `FileWriter(String fileName, Charset charset)`
  Constructs a `FileWriter` given a file name and charset.
  ``
  `FileWriter(String fileName, Charset charset, boolean append)`
  Constructs a `FileWriter` given a file name, charset and a boolean indicating whether to append the data written.
  ``
  `InputStreamReader(InputStream in, Charset cs)`
  Creates an InputStreamReader that uses the given charset.
  ``
  `OutputStreamWriter(OutputStream out, Charset cs)`
  Creates an OutputStreamWriter that uses the given charset.
  ``
  `PrintStream(File file, Charset charset)`
  Creates a new print stream, without automatic line flushing, with the specified file and charset.
  ``
  `PrintStream(OutputStream out, boolean autoFlush, Charset charset)`
  Creates a new print stream, with the specified OutputStream, line flushing and charset.
  ``
  `PrintStream(String fileName, Charset charset)`
  Creates a new print stream, without automatic line flushing, with the specified file name and charset.
  ``
  `PrintWriter(File file, Charset charset)`
  Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.
  ``
  `PrintWriter(OutputStream out, boolean autoFlush, Charset charset)`
  Creates a new PrintWriter from an existing OutputStream.
  ``
  `PrintWriter(String fileName, Charset charset)`
  Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

- ## Uses of Charset in java.lang

  Methods in java.lang with parameters of type Charset
  Modifier and Type
  Method
  Description
  `final BufferedReader`
  Process.`errorReader(Charset charset)`
  Returns a `BufferedReader` connected to the standard error of this process using a Charset.
  `byte[]`
  String.`getBytes(Charset charset)`
  Encodes this `String` into a sequence of bytes using the given charset, storing the result into a new byte array.
  `final BufferedReader`
  Process.`inputReader(Charset charset)`
  Returns a `BufferedReader` connected to the standard output of this process using a Charset.
  `final BufferedWriter`
  Process.`outputWriter(Charset charset)`
  Returns a `BufferedWriter` connected to the normal input of the process using a Charset.
  Constructors in java.lang with parameters of type Charset
  Modifier
  Constructor
  Description
  ``
  `String(byte[] bytes, int offset, int length, Charset charset)`
  Constructs a new `String` by decoding the specified subarray of bytes using the specified charset.
  ``
  `String(byte[] bytes, Charset charset)`
  Constructs a new `String` by decoding the specified array of bytes using the specified charset.

- ## Uses of Charset in java.lang.foreign

  Methods in java.lang.foreign with parameters of type Charset
  Modifier and Type
  Method
  Description
  `default MemorySegment`
  SegmentAllocator.`allocateFrom(String str, Charset charset)`
  Converts a Java string into a null-terminated C string using the provided charset, and storing the result into a memory segment.
  `String`
  MemorySegment.`getString(long offset, Charset charset)`
  Reads a null-terminated string from this segment at the given offset, using the provided charset.
  `void`
  MemorySegment.`setString(long offset, String str, Charset charset)`
  Writes the given string into this segment at the given offset, converting it to a null-terminated byte sequence using the provided charset.

- ## Uses of Charset in java.net

  Methods in java.net with parameters of type Charset
  Modifier and Type
  Method
  Description
  `static String`
  URLDecoder.`decode(String s, Charset charset)`
  Decodes an `application/x-www-form-urlencoded` string using a specific Charset.
  `static String`
  URLEncoder.`encode(String s, Charset charset)`
  Translates a string into `application/x-www-form-urlencoded` format using a specific Charset.

- ## Uses of Charset in java.net.http

  Methods in java.net.http with parameters of type Charset
  Modifier and Type
  Method
  Description
  `static <S extends Flow.Subscriber<? super String>, T>
  HttpResponse.BodySubscriber<T>`
  HttpResponse.BodySubscribers.`fromLineSubscriber(S subscriber, Function<? super S, ? extends T> finisher, Charset charset, String lineSeparator)`
  Returns a body subscriber that forwards all response body to the given `Flow.Subscriber`, line by line.
  `static HttpResponse.BodySubscriber<Stream<String>>`
  HttpResponse.BodySubscribers.`ofLines(Charset charset)`
  Returns a `BodySubscriber` which streams the response body as a `Stream``<String>`, where each string in the stream corresponds to a line as defined by `BufferedReader.lines()`.
  `static HttpRequest.BodyPublisher`
  HttpRequest.BodyPublishers.`ofString(String s, Charset charset)`
  Returns a request body publisher whose body is the given `String`, converted using the given character set.
  `static HttpResponse.BodyHandler<String>`
  HttpResponse.BodyHandlers.`ofString(Charset charset)`
  Returns a `BodyHandler<String>` that returns a `BodySubscriber``<String>` obtained from `BodySubscribers.ofString(Charset)`.
  `static HttpResponse.BodySubscriber<String>`
  HttpResponse.BodySubscribers.`ofString(Charset charset)`
  Returns a body subscriber which stores the response body as a `String` converted using the given `Charset`.

- ## Uses of Charset in java.nio.channels

  Methods in java.nio.channels with parameters of type Charset
  Modifier and Type
  Method
  Description
  `static Reader`
  Channels.`newReader(ReadableByteChannel ch, Charset charset)`
  Constructs a reader that decodes bytes from the given channel according to the given charset.
  `static Writer`
  Channels.`newWriter(WritableByteChannel ch, Charset charset)`
  Constructs a writer that encodes characters according to the given charset and writes the resulting bytes to the given channel.

- ## Uses of Charset in java.nio.charset

  Classes in java.nio.charset that implement interfaces with type arguments of type Charset
  Modifier and Type
  Class
  Description
  `class`
  `Charset`
  A named mapping between sequences of sixteen-bit Unicode code units and sequences of bytes.
  Fields in java.nio.charset declared as Charset
  Modifier and Type
  Field
  Description
  `static final Charset`
  StandardCharsets.`ISO_8859_1`
  ISO Latin Alphabet No. 1, also known as ISO-LATIN-1.
  `static final Charset`
  StandardCharsets.`US_ASCII`
  Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
  `static final Charset`
  StandardCharsets.`UTF_16`
  Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark.
  `static final Charset`
  StandardCharsets.`UTF_16BE`
  Sixteen-bit UCS Transformation Format, big-endian byte order.
  `static final Charset`
  StandardCharsets.`UTF_16LE`
  Sixteen-bit UCS Transformation Format, little-endian byte order.
  `static final Charset`
  StandardCharsets.`UTF_32`
  Thirty-two-bit UCS Transformation Format, byte order identified by an optional byte-order mark.
  `static final Charset`
  StandardCharsets.`UTF_32BE`
  Thirty-two-bit UCS Transformation Format, big-endian byte order.
  `static final Charset`
  StandardCharsets.`UTF_32LE`
  Thirty-two-bit UCS Transformation Format, little-endian byte order.
  `static final Charset`
  StandardCharsets.`UTF_8`
  Eight-bit UCS Transformation Format.
  Methods in java.nio.charset that return Charset
  Modifier and Type
  Method
  Description
  `final Charset`
  CharsetDecoder.`charset()`
  Returns the charset that created this decoder.
  `final Charset`
  CharsetEncoder.`charset()`
  Returns the charset that created this encoder.
  `static Charset`
  Charset.`defaultCharset()`
  Returns the default charset of this Java virtual machine.
  `Charset`
  CharsetDecoder.`detectedCharset()`
  Retrieves the charset that was detected by this decoder (optional operation).
  `static Charset`
  Charset.`forName(String charsetName)`
  Returns a charset object for the named charset.
  `static Charset`
  Charset.`forName(String charsetName, Charset fallback)`
  Returns a charset object for the named charset.
  Methods in java.nio.charset that return types with arguments of type Charset
  Modifier and Type
  Method
  Description
  `static SortedMap<String,Charset>`
  Charset.`availableCharsets()`
  Constructs a sorted map from canonical charset names to charset objects.
  Methods in java.nio.charset with parameters of type Charset
  Modifier and Type
  Method
  Description
  `final int`
  Charset.`compareTo(Charset that)`
  Compares this charset to another.
  `abstract boolean`
  Charset.`contains(Charset cs)`
  Tells whether or not this charset contains the given charset.
  `static Charset`
  Charset.`forName(String charsetName, Charset fallback)`
  Returns a charset object for the named charset.
  Constructors in java.nio.charset with parameters of type Charset
  Modifier
  Constructor
  Description
  `protected`
  `CharsetDecoder(Charset cs, float averageCharsPerByte, float maxCharsPerByte)`
  Initializes a new decoder.
  `protected`
  `CharsetEncoder(Charset cs, float averageBytesPerChar, float maxBytesPerChar)`
  Initializes a new encoder.
  `protected`
  `CharsetEncoder(Charset cs, float averageBytesPerChar, float maxBytesPerChar, byte[] replacement)`
  Initializes a new encoder.

- ## Uses of Charset in java.nio.charset.spi

  Methods in java.nio.charset.spi that return Charset
  Modifier and Type
  Method
  Description
  `abstract Charset`
  CharsetProvider.`charsetForName(String charsetName)`
  Retrieves a charset for the given charset name.
  Methods in java.nio.charset.spi that return types with arguments of type Charset
  Modifier and Type
  Method
  Description
  `abstract Iterator<Charset>`
  CharsetProvider.`charsets()`
  Creates an iterator that iterates over the charsets supported by this provider.

- ## Uses of Charset in java.nio.file

  Methods in java.nio.file with parameters of type Charset
  Modifier and Type
  Method
  Description
  `static Stream<String>`
  Files.`lines(Path path, Charset cs)`
  Read all lines from a file as a `Stream`.
  `static BufferedReader`
  Files.`newBufferedReader(Path path, Charset cs)`
  Opens a file for reading, returning a `BufferedReader` that may be used to read text from the file in an efficient manner.
  `static BufferedWriter`
  Files.`newBufferedWriter(Path path, Charset cs, OpenOption... options)`
  Opens or creates a file for writing, returning a `BufferedWriter` that may be used to write text to the file in an efficient manner.
  `static List<String>`
  Files.`readAllLines(Path path, Charset cs)`
  Read all lines from a file.
  `static String`
  Files.`readString(Path path, Charset cs)`
  Reads all characters from a file into a string, decoding from bytes to characters using the specified charset.
  `static Path`
  Files.`write(Path path, Iterable<? extends CharSequence> lines, Charset cs, OpenOption... options)`
  Write lines of text to a file.
  `static Path`
  Files.`writeString(Path path, CharSequence csq, Charset cs, OpenOption... options)`
  Write a CharSequence to a file.

- ## Uses of Charset in java.util

  Methods in java.util with parameters of type Charset
  Modifier and Type
  Method
  Description
  `void`
  Properties.`storeToXML(OutputStream os, String comment, Charset charset)`
  Emits an XML document representing all of the properties contained in this table, using the specified encoding.
  Constructors in java.util with parameters of type Charset
  Modifier
  Constructor
  Description
  ``
  `Formatter(File file, Charset charset, Locale l)`
  Constructs a new formatter with the specified file, charset, and locale.
  ``
  `Formatter(OutputStream os, Charset charset, Locale l)`
  Constructs a new formatter with the specified output stream, charset, and locale.
  ``
  `Formatter(String fileName, Charset charset, Locale l)`
  Constructs a new formatter with the specified file name, charset, and locale.
  ``
  `Scanner(File source, Charset charset)`
  Constructs a new `Scanner` that produces values scanned from the specified file.
  ``
  `Scanner(InputStream source, Charset charset)`
  Constructs a new `Scanner` that produces values scanned from the specified input stream.
  ``
  `Scanner(ReadableByteChannel source, Charset charset)`
  Constructs a new `Scanner` that produces values scanned from the specified channel.
  ``
  `Scanner(Path source, Charset charset)`
  Constructs a new `Scanner` that produces values scanned from the specified file.

- ## Uses of Charset in java.util.zip

  Constructors in java.util.zip with parameters of type Charset
  Modifier
  Constructor
  Description
  ``
  `ZipFile(File file, int mode, Charset charset)`
  Opens a new `ZipFile` to read from the specified `File` object in the specified mode.
  ``
  `ZipFile(File file, Charset charset)`
  Opens a ZIP file for reading given the specified File object.
  ``
  `ZipFile(String name, Charset charset)`
  Opens a ZIP file for reading.
  ``
  `ZipInputStream(InputStream in, Charset charset)`
  Creates a new ZIP input stream.
  ``
  `ZipOutputStream(OutputStream out, Charset charset)`
  Creates a new ZIP output stream.

- ## Uses of Charset in javax.tools

  Methods in javax.tools with parameters of type Charset
  Modifier and Type
  Method
  Description
  `StandardJavaFileManager`
  DocumentationTool.`getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset)`
  Returns a new instance of the standard file manager implementation for this tool.
  `StandardJavaFileManager`
  JavaCompiler.`getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset)`
  Returns a new instance of the standard file manager implementation for this tool.

- ## Uses of Charset in jdk.jshell

  Methods in jdk.jshell that return Charset
  Modifier and Type
  Method
  Description
  `Charset`
  JShellConsole.`charset()`
  Returns the `Charset` object used for the `Console`.