package com.itheima.ZiFuLiu;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class ReadDemo {
public static void main(String[] args) throws IOException {
InputStreamReader isp=new InputStreamReader(new FileInputStream("FileDemo\\javase.txt"),"GBK");
/*int ch;
while((ch=isp.read())!=-1){
System.out.print((char)ch);
}*/
char[]chs=new char[1024];
int len;
while((len=isp.read(chs))!=-1){
System.out.print(new String(chs,0,len));
}
isp.close();
}
}
|
|