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());
}
}
}

Recommended Answers

All 4 Replies

1. Look at the brackets in your while statement.
2. Next time post your code in code tags and post the complete compiler error message (including the line number)

I was confused by James' post at first, and then I realized that what he calls "brackets" are what I call "parentheses".

Brackets, to me, are [] and {}. The trouble here is with ().

Next time post your code in code tags and post the complete compiler error message (including the line number)

And would it kill you to try to spell out the problem?

Brackets are tall punctuation marks used in matched pairs within text, to set apart or interject other text. In the United States, "bracket" usually refers specifically to the "square" or "box" type; in British usage, it normally refers to a parenthesis mark.

http://en.wikipedia.org/wiki/Bracket

You say color, I say colour... actually I wasn't aware of this particular quirk in US "English", but I'll avoid it in future.
:-)

Two nations separated by a common language, isn't that what they say? :)

Since we have no way of knowing which variant the original poster prefers, I guess it's good they get both.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.