File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Error reading from input file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error reading from input file?" Watch "Error reading from input file?" New topic

Error reading from input file?

Tom Brodhead

Joined: Jan 02, 2011
Posts: 25
I'm trying to open a text file for input using the Eclipse IDE and I'm receiving error messages I can't resolve. Here's my code:

Eclipse flags the "String file" line as an error with the following message:

Syntax error on token ";", { expected after this token

It also flags the final } with this message:

Syntax error, insert "}" to complete ClassBody

What am I doing wrong here?

Tom Reilly

Joined: Jun 01, 2010
Posts: 618
You cannot just add code to a class. You have to put the code in a method. Also, Stdout is not Java. See below.
Tom Brodhead

Joined: Jan 02, 2011
Posts: 25
Thanks--this was an embarrassing brain fart--forgot to put it into a method. I'm actually planning on calling the resulting method from a class with a main() method elsewhere; the Stdout routine is part of the larger package this belongs to.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Error reading from input file?
It's not a secret anymore!