import java.io.*;
public class EcodeStream {
/**
* InputStreamReader和OutputStreamWriter字符编码转换
两个对象的构造函数里加入字符编码集;
*/
public static void main(String[] args) throws IOException{
//Write();
read();
}
public static void Write() throws IOException
{
OutputStreamWriter ow = new OutputStreamWriter(
new FileOutputStream("D:\\utf.txt"),"UTF-8");
ow.write("你好");
ow.close();
}
public static void read() throws IOException, FileNotFoundException{
InputStreamReader ir = new InputStreamReader(
new FileInputStream("D:\\utf.txt"),"utf-8");
char[] buf = new char[1024];
int len = ir.read(buf);
String str = new String(buf,0,len);
System.out.println(str);
}
}