读取文件中文乱码,英文可以
程序代码:
public static void main(String[] args) throws Exception{ File afile=new File("C:/Users/liudenghong/Downloads/b.txt"); FileInputStream red=new FileInputStream(afile); InputStreamReader in=new InputStreamReader(red,"UTF-8"); BufferedReader buf=new BufferedReader(in); String line=buf.readLine(); while(line!=null){ System.out.println(line); line=buf.readLine(); } }