Java IO Tutorial - Java Charset.compareTo(Charset that)


Charset.compareTo(Charset that) has the following syntax.

public final int compareTo(Charset that)


In the following code shows how to use Charset.compareTo(Charset that) method.

//from  ww w  .  j  a v  a  2s  .com
import java.nio.charset.Charset;

public class Main {

  public static void main(String[] args) {
    Charset csets = Charset.forName("UTF16");
    Charset csets1 = Charset.forName("UTF-8");


The code above generates the following result.