Open In App

Charset isRegistered() method in Java with Examples

Last Updated : 28 Mar, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The isRegistered() method is a built-in method of the java.nio.charset checks if a given charset is registered or not under the IANA Charset Registry.

Syntax:

public final boolean isRegistered()

Parameters: The function does not accepts any parameter.

Return Value: The function returns a boolean value. It returns true if it is registered, else it returns false.

Below is the implementation of the above function:

Program 1:




// Java program to demonstrate
// the above function
  
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Map;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Generate the Charset
        Charset first
            = Charset.forName("ISO-2022-CN");
  
        // Check if this Charset is registered
        System.out.println(first.isRegistered());
    }
}


Output:

true

Program 2:




// Java program to demonstrate
// the above function
  
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Map;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Generate the Charset
        Charset second
            = Charset.forName("x-windows-949");
  
        // Check if this Charset is registered
        System.out.println(second.isRegistered());
    }
}


Output:

false

Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/Charset.html#isRegistered–



Similar Reads

java.nio.charset.Charset Class in Java
In Java, Charset is a mapping technique used in Java to map the 16-bit Unicode sequence and sequences of bytes. It is also used to encode and decode the string data text into different character encoding. It comes under java.nio.charset.Charset package. The charset must begin with a number or letter. Every charset can decode and encode. For constru
2 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 machine. In short, the result will vary from machine to
1 min read
Charset forName() method in Java with Examples
The forName() method is a built-in method of the java.nio.charset returns a charset object for the named charset. In this function we pass a canonical name or an alias and its respective charset name is returned. Syntax: public static Charset forName?(String charsetName) Parameters: The function accepts a single mandatory parameter charsetName whic
3 min read
Charset hashCode() method in Java with Examples
The hashCode() method is a built-in method of the java.nio.charset returns the computed hashcode of any given charset. Syntax: public final int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns the computed hashcode for the charset. Below is the implementation of the above function: Program 1: //
1 min read
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 implementation of the above function: Program 1: // Ja
1 min read
Charset newEncoder() method in Java with Examples
The newEncoder() method is a built-in method of the java.nio.charset constructs a new encoder for this charset. Syntax: public abstract CharsetEncoder newEncoder() Parameters: The function does not accepts any parameter. Return Value: The function returns a new encoder for this charset Errors and Exceptions: The function throws UnsupportedOperation
1 min read
Charset isSupported() method in Java with Examples
The isSupported() method is a built-in method of the java.nio.charset checks if a given charset is supported or not. Syntax: public final boolean isSupported() Parameters: The function accepts a single mandatory parameter charset Name which specifies the canonical name or the alias name which is to be checked. Return Value: The function returns a b
2 min read
Charset newDecoder() method in Java with Examples
The newDecoder() method is a built-in method of the java.nio.charset constructs a new decoder for this charset. . Syntax: public abstract CharsetDecoder newDecoder() Parameters: The function does not accepts any parameter. Return Value: The function returns a new decoder for this charset Below is the implementation of the above function: Program 1:
1 min read
Charset equals() method in Java with Examples
The equals() method is a built-in method of the java.nio.charset checks if a given object of charset is equal to another given object of the charset. Two charsets are considered equal if, and only if, they have the same canonical names. A charset is never equal to any other type of object. Syntax: public final boolean equals(Object other) Parameter
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 which specifies the charset to be compared with. Re
1 min read
Practice Tags :