encoding format conversion

package com.tianmushanlu.util;

import java.nio.charset.Charset;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Encoding format conversion
 *
 *
 *
 */
public class CharSetUtil {
	private static final Logger LOGGER = LoggerFactory.getLogger(CharSetUtil.class);
	
	public static Charset chatset(String charsetName) {
		Charset code = null;
		try {
			if(StringUtils.isBlank(charsetName)) {
				return code;
			}	
			code = Charset.forName(charsetName);
			
		} catch (Exception e) {
			code = null;
			LOGGER.error("Failed:", charsetName);
		}
		return code;
	}
	
	public static void main(String[] args) {
		Charset chatset = chatset("gbk");
		System.out.println(chatset);
	}
}


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327073255&siteId=291194637