I am confused. In the program below, the read method converts the fin object into what appears to characters. That's why the variable "i" is converted into the character type. I thought the character type could only be used to display one letter, number, or other symbol. Why then was the whole file printed to screen. Please explain to me.
Thanks,
Truck35
try { // read bytes until EOF is encountered do { i = fin.read(); if(i != -1) System.out.print((char) i); } while(i != -1); } catch(IOException exc) { System.out.println("Error reading file."); }
--- Update ---
I was just wondering. The read method reads the file each byte at a time. Then it returns -1 when done or a error message if it dosn't finish. Am I able to see characters because of the conversion used in the "println" statement. Please let me know if this is true.
Thanks,
Truck35