package com.tianmushanlu.util;
import java.nio.charset.Charset;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 编码格式转化
*
*
*
*/
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("失败 :", charsetName);
}
return code;
}
public static void main(String[] args) {
Charset chatset = chatset("gbk");
System.out.println(chatset);
}
}
编码格式转化
最新推荐文章于 2024-03-22 15:46:58 发布