Javatpoint Logo
Javatpoint Logo

Java NIO Charset

The concept of charset is introduced in JDK 1.4 using the package java.nio.charset.Charset. It plays an important role in encoding and decoding between the given charset and UNICODE.

The name of charset must follow certain rules. It must begin with the number or letter. Charset method is also safe for use in the multithreading environment.


Standard charsets

The list of charset supported in java are given below:

UTF-8: This is 8 bit UCS transformation format.

US-ASCII: Seven bit ASCII characters.

UTF-16LE: This is 16 bit UCS transformation with little endian byte order.

ISO-8859-1: ISO Latin alphabet

UTF-16: 16 bit UCS transformation format.

UTF-16BE: This is 16 bit UCS transformation format with big endian byte order

Charset.displayName() in Java NIO

This method is used to return a canonical name of charset.

Charset.encode() in Java NIO

This method is used to encode the charbuffer of UNICODE charset into the byte buffer of given charset.

Charset.decode() in Java NIO

This method is used to decode the string of a given charset into charbuffer of Unicode charset.

Basic Charset Example

Output:






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA