CharsetDecoder charset() in Java with examples Last Updated : 23 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report CharsetDecoder.charset() is an in-built method in Java of CharsetDecoder class that returns the charset that created this decoder. Syntax: public final Charset charset() Parameter: The function does not accepts any parameter. Return value: The function returns the decoder's charset. Program below demonstrate the above mentioned function: Program 1: Java // Java program below demonstrate // CharsetDecoder.charset function import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; public class Main { public static void main(String[] argv) throws Exception { Charset charset = Charset.forName("ISO-8859-1"); // initialising CharsetDecoder cd CharsetDecoder cd = charset.newDecoder(); // print charset of decoder cd System.out.println(cd.charset()); } } Output: ISO-8859-1 Program 2: Java // Java program below demonstrate // CharsetDecoder.charset function import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; public class Main { public static void main(String[] argv) throws Exception { Charset charset = Charset.forName("ISO-8859-2"); // initialising CharsetDecoder cd CharsetDecoder cd = charset.newDecoder(); // print charset of decoder cd System.out.println(cd.charset()); } } Output: ISO-8859-2 Comment More infoAdvertise with us Next Article Charset defaultCharset() method in Java with Examples T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-Functions Java-CharsetDecoder Practice Tags : JavaMisc Similar Reads CharsetEncoder charset() method in Java with Examples The charset() method is a built-in method of the java.nio.charset.CharsetEncoder returns the charset that created this encoder. Syntax: public final Charset charset() Parameters: The function does not accepts any parameter. Return Value: The function returns this encoder's charset. Below is the impl 1 min read CharsetDecoder averageCharsPerByte() method in Java with Examples The averageCharsPerByte() method is a built-in method of the java.nio.charset.CharsetDecoder class which returns the average number of characters that will be produced for each byte of input. This heuristic value may be used to estimate the size of the output buffer required for a given input sequen 2 min read Charset compareTo() method in Java with Examples The compareTo() method is a built-in method of the java.nio.charset compares two charsets with each other. A comparison is done by their canonical names, without regard to case. Syntax: public final int compareTo?(Charset second) Parameters: The function accepts a single mandatory parameter second w 1 min read Charset defaultCharset() method in Java with Examples The defaultCharset() method is a built-in method of the java.nio.charset which returns the charset object for the default charset. The default charset is basically determined by the Java virtual machine and it basically depends on the charset which is in the underlying operating system of the machin 1 min read Character.charValue() in Java with examples Java.lang.Character.charValue() is a built-in method in Java that returns the value of this character object. This method converts the Character object into its primitive data type char. Syntax: public char charValue() The function does not accepts any parameter. Return Type: This method returns the 2 min read CharsetDecoder reset() method in Java with Examples The reset() method is a built-in method of the java.nio.charset.CharsetDecoder class which resets this CharsetDecoder and clears its internal state. Syntax: public final CharsetDecoder reset() Parameters: The function does not accepts any parameter. Return Value: The function returns this CharsetDec 1 min read Like