IO流问题
int c =
0;
while((c=isr.read())!=-
1){ .
System.
out.print((
char)c);
1 首先这里按照字符流读取,即读到的是Unicode编码的字符; 2.“向上兼容”–即:不同数据类型的数据参与运算,数据类型要强制转换,转换的方向是
(unsigned)char,(unsigned)short->int->unsigned->long->unsigned long->float->double->longdouble。
3.不管C定义是char还是int ,它都是作为一个容器来存储读到的数据
the next byte of data, or -1 if the end of the file is reached;若读完结束返回-1,而不是计数;
4: 在定义C 容器时候,因为“向上兼容”和最后要返回-1来说;定义为int 最合适;输出时,则需要强制类型转换;
5: 区别:
int c = read(); // 存入C容器中,结束返回-1; int c = read(byte,star,length); //计数,结束返回-1;
感谢阅读,欢迎指正!!
转载请注明原文地址: https://ju.6miu.com/read-26274.html