Java examples for Internationalization:Charset
get Charset Decoder
//package com.java2s; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CodingErrorAction; public class Main { public static void main(String[] argv) throws Exception { String charsetName = "java2s.com"; System.out.println(getCharsetDecoder(charsetName)); }/* www .ja v a2 s . co m*/ public static CharsetDecoder getCharsetDecoder(String charsetName) { Charset charset = Charset.forName(charsetName); CharsetDecoder charsetDecoder = charset.newDecoder(); charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE); charsetDecoder.onUnmappableCharacter(CodingErrorAction.REPLACE); return charsetDecoder; } }