81,092
社区成员
发帖
与我相关
我的任务
分享
import java.io.*;
public class Codetest
{
public static void main(String[] args) throws Exception
{
File file=new File("文档.txt");
BufferedReader bf=new BufferedReader(new FileReader(file));
String s=bf.readLine();
byte[] b=s.getBytes("utf-8");
String s2=new String(b,"gbk");
System.out.println("s2 is "+s2);
}
}
文档.txt用utf-8编码方式存入两个字:张三
输出:
s2 is 寮犱笁