第一个while语句条件,为什么一串字符可以赋值给字符变量ch,然后第二个while语句中data=fin.read()为什么读取的字符能赋值给整型变量data
public static void main(String[] args) {
FileInputStream fin;
FileOutputStream fout;
char ch;
int data;
try {
fin = new FileInputStream(FileDescriptor.in);
fout = new FileOutputStream("d:\\java程序设计\\1.txt");
System.out.println("请输入一串字符,并以#结束");
while ((ch = (char) fin.read()) != '#') {
fout.write(ch);
}
fin.close();
fout.close();
System.out.println();
fin = new FileInputStream("d:\\java程序设计\\1.txt");
fout = new FileOutputStream(FileDescriptor.out);
while (fin.available() > 0) {
data = fin.read();
fout.write(data);
}
fin.close();
fout.close();
}
catch(FileNotFoundException e){
System.out.println("文件没找到");
}
catch(IOException e){
}
}