is Charset correct this the current String - Android java.lang

Android examples for java.lang:String Unicode

Description

is Charset correct this the current String

Demo Code


//package com.java2s;

public class Main {
    public static boolean isCharset(String str, String charset,
            int judgeCharsetLength) {
        try {//from www .  j  av a  2  s.co m
            String temp = str.length() > judgeCharsetLength ? str
                    .substring(0, judgeCharsetLength) : str;
            return temp.equals(new String(temp.getBytes(charset), charset));
        } catch (Throwable e) {
        }
        return false;
    }
}

Related Tutorials