public static void readText() throws Exception{
InputStreamReader isw = new InputStreamReader(new FileInputStream("demo.txt"),"UTF-8");
char[] buf = new char[20];
int len = isw.read(buf);
String str = new String(buf,0,len);
sop(str);
isw.close();
}
是不是已经知道数据不多的情况 所以不判断读的末尾即-1的》??? |