本帖最后由 sunxiaohong 于 2015-5-6 21:42 编辑
public class Demo {
public static void main(String[] args) throws IOException{
InputStreamReader in = new InputStreamReader(new FileInputStream("OSW_GBK_2.txt"),"GBK");
//一次读取一个字符
/*int n = 0;
while((n = in.read()) != -1){
System.out.print((char)n);
}*/
System.out.println("----------------------------------------");
//一次读取一个字符数组
char[] charArray = new char[1024];
int len = 0;
while((len = in.read(charArray)) != -1){
System.out.print(new String(charArray,0,len));
}
//释放资源
in.close();
}
}
这是我昨天的课,讲的IO 字符流,求大神解释一下,System.out.print(new String(charArray,0,len));这句话的具体含义,弄了半天没明白??? |