????*/????
??public??String??toUTF_16BE(String??str)??throws??UnsupportedEncodingException{????
????return??this.changeCharset(str,??UTF_16BE);????
??}????
??/**??
????*??将字符编码转换成UTF-16LE码??

????*/????
??public??String??toUTF_16LE(String??str)??throws??UnsupportedEncodingException{????
????return??this.changeCharset(str,??UTF_16LE);????
??}????
??/**??
????*??将字符编码转换成UTF-16码??
????*/????
??public??String??toUTF_16(String??str)??throws??UnsupportedEncodingException{????
????return??this.changeCharset(str,??UTF_16);????
??}????
??/**??
????*??将字符编码转换成GBK码??
????*/????
??public??String??toGBK(String??str)??throws??UnsupportedEncodingException{????
????return??this.changeCharset(str,??GBK);????
??}????
??????
??/**??
????*??字符串编码转换的实现方法??
????*??@param??str????待转换编码的字符串??
????*??@param??newCharset??目标编码??
????*??@return??
????*??@throws??UnsupportedEncodingException??
????*/????
??public??String??changeCharset(String??str,??String??newCharset)????
??????throws??UnsupportedEncodingException??{????
????if??(str??!=??null)??{????
??????//用默认字符编码解码字符串。????
??????byte[]??bs??=??str.getBytes();????
??????//用新的字符编码生成字符串????
??????return??new??String(bs,??newCharset);????
????}????
????return??null;????
??}????
??/**??
????*??字符串编码转换的实现方法??
????*??@param??str????待转换编码的字符串??
????*??@param??oldCharset??原编码??
????*??@param??newCharset??目标编码??
????*??@return??
????*??@throws??UnsupportedEncodingException??
????*/????
??public??String??changeCharset(String??str,??String??oldCharset,??String??newCharset)????
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-59927-2.html
看完觉得好尴尬
甲午海战北洋水师舰也不少
让百姓有了更大选择权