【Java开源代码栏目提醒】:以下是网学会员为您推荐的Java开源代码-TransFormat.java,希望本篇文章对您学习有所帮助。
/*
* Created on 2004-9-21
*
* To change the template for this generated file go to
* Window>Preferences>
Java>Code Generation>Code and Comments
*/
package util;
import java.io.*;
/**
* @author WineFox
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class TransFormat {
public static String unicode2GB(String strIn){
byte b[];
String strOut=null;
if (strIn==null||((strIn.trim()).equals("")))
return strIn;
try {
b=strIn.getBytes("GBK");
strOut=new String(b,"ISO8859_1");
}catch(UnsupportedEncodingException e){
}
return strOut;
}
public static String GB2unicode(String strIn){
String strOut=null;
if (strIn==null||((strIn.trim()).equals(""))) return strIn;
try {
byte b[]=strIn.getBytes("ISO8859_1");
strOut=new String(b,"GBK");}
catch(Exception e){}
return strOut;
}
}