首页 > 代码库 > JAVA的编码转换测试

JAVA的编码转换测试

package test;

import java.io.UnsupportedEncodingException;

/**
 *
 * @author jim
 */
public class Test {

    /**
     * @param args the command line arguments
     * @throws java.io.UnsupportedEncodingException
     */
    public static void main(String[] args) throws UnsupportedEncodingException {
        // TODO code application logic here
        String str = "你好";
        byte[] gbkBytes = str.getBytes("GBK");
        String gbkStr = new String(gbkBytes, "GBK");
        System.out.println(new String(gbkStr.getBytes("utf-8")));
    }
    
}

 

JAVA的编码转换测试