import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
/**
* 测试类, 中文乱码处理: InputStreamReader / OutputStreamWriter
* @author Administrator
*
*/
public class Test9 {
public static void main(String[] args) {
try {
//创建IO流对象
InputStreamReader isr = new InputStreamReader(new FileInputStream("file/demo/name.txt"), "utf-8");
BufferedReader br = new BufferedReader(isr);
String line = null;
while((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
isr.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
中文乱码处理: InputStreamReader / OutputStreamWriter
最新推荐文章于 2024-08-19 10:43:09 发布