| Package | Description | 
|---|---|
| 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.net | Provides the classes for implementing networking applications. | 
| java.util | Contains the collections framework, legacy collection classes, event model,
date and time facilities, internationalization, and miscellaneous utility
classes (a string tokenizer, a random-number generator, and a bit array). | 
| java.util.logging | 
Provides the classes and interfaces of 
the JavaTM 2
 platform's core logging facilities. | 
| javax.xml.bind.helpers | 
        JAXB Provider Use Only: Provides partial default implementations for 
        some of the javax.xml.bind interfaces. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| String | ByteArrayOutputStream. toString(String charsetName)Converts the buffer's contents into a string by decoding the bytes using
 the named  charset. | 
| Constructor | Description | 
|---|---|
| InputStreamReader(InputStream in,
                 String charsetName)Creates an InputStreamReader that uses the named charset. | |
| OutputStreamWriter(OutputStream out,
                  String charsetName)Creates an OutputStreamWriter that uses the named charset. | |
| PrintStream(File file,
           String csn)Creates a new print stream, without automatic line flushing, with the
 specified file and charset. | |
| PrintStream(OutputStream out,
           boolean autoFlush,
           String encoding)Creates a new print stream. | |
| PrintStream(String fileName,
           String csn)Creates a new print stream, without automatic line flushing, with the
 specified file name and charset. | |
| PrintWriter(File file,
           String csn)Creates a new PrintWriter, without automatic line flushing, with the
 specified file and charset. | |
| PrintWriter(String fileName,
           String csn)Creates a new PrintWriter, without automatic line flushing, with the
 specified file name and charset. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| byte[] | String. getBytes(String charsetName)Encodes this  Stringinto a sequence of bytes using the named
 charset, storing the result into a new byte array. | 
| Constructor | Description | 
|---|---|
| String(byte[] bytes,
      int offset,
      int length,
      String charsetName)Constructs a new  Stringby decoding the specified subarray of
 bytes using the specified charset. | |
| String(byte[] bytes,
      String charsetName)Constructs a new  Stringby decoding the specified array of bytes
 using the specified charset. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| static String | URLDecoder. decode(String s,
      String enc)Decodes a  application/x-www-form-urlencodedstring using a specific
 encoding scheme. | |
| static String | URLEncoder. encode(String s,
      String enc)Translates a string into  application/x-www-form-urlencodedformat using a specific encoding scheme. | 
| Constructor | Description | 
|---|---|
| Formatter(File file,
         String csn)Constructs a new formatter with the specified file and charset. | |
| Formatter(File file,
         String csn,
         Locale l)Constructs a new formatter with the specified file, charset, and
 locale. | |
| Formatter(OutputStream os,
         String csn)Constructs a new formatter with the specified output stream and
 charset. | |
| Formatter(OutputStream os,
         String csn,
         Locale l)Constructs a new formatter with the specified output stream, charset,
 and locale. | |
| Formatter(String fileName,
         String csn)Constructs a new formatter with the specified file name and charset. | |
| Formatter(String fileName,
         String csn,
         Locale l)Constructs a new formatter with the specified file name, charset, and
 locale. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| void | StreamHandler. setEncoding(String encoding)Set (or change) the character encoding used by this Handler. | |
| void | Handler. setEncoding(String encoding)Set the character encoding used by this Handler. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| protected String | AbstractMarshallerImpl. getJavaEncoding(String encoding)Gets the corresponding Java encoding name from an IANA name. | 
 Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2025, Oracle and/or its affiliates.  All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.