In the example given in the Oracle Java Tutorial they are trying to read characters as integers… .
Why and how does that work?
try {
inputStream = new FileReader("xanadu.txt");
outputStream = new FileWriter("characteroutput.txt");
int c;
while ((c = inputStream.read()) != -1) {
outputStream.write(c);
}
If you read char, there would be no value you could use for end of file.
By using a larger type
int, its possible to have every possible character AND another symbol which means end of file.