0

i have been strugling to identify my error but i have failed to solve the problem my code errors is incompatible types in line 11.

import java.io.*;
public class Appliance
{
public static void main(String args[])
{
try
{
File file=new File("Name.txt");
FileReader f=new FileReader(file);
int ch;
while(ch=f.read())
{
System.out.print((char)ch);
}
}
catch(FileNotFoundException fnfe)
{
System.out.println("Exception: "+fnfe.toString());
}
catch(IOException ioe)
{
System.out.println("Exception: "+ioe.toString());
}
}
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by masijade
0

While needs a boolean.

while((ch = f.read()) != -1)

Now, you look at the API docs and/or the Java IO Tutorials and tell me what that line is now doing and how it is different from yours.

Edit: And format your code!

Edited by masijade: typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.