Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes FileReader issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "FileReader issues" Watch "FileReader issues" New topic
Author

FileReader issues

Jax Laakso
Greenhorn

Joined: Dec 07, 2001
Posts: 23
I'm having some problems compiling a program. I'm using a FileReader to read in a .txt file and then do some fun extraction on the strings before spitting it out to the screen at the moment.
I keep getting:
Error : Exception java.io.FileNotFoundException must be caught, or it must be declared in the throws clause
of this method.
FindCosts.java line 21 new FileReader(input));
When I try to compile it. I am using CodeWarrior 5 for the Mac if that makes any difference. This is my first time using FileReader so I'm wondering if I did it wrong. The code is below.


[This message has been edited by Cindy Glass (edited December 14, 2001).]
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Jax,
Any time you use any I/O method except File you are required to use a try/catch loop:

Regards,
Manfred.
Jax Laakso
Greenhorn

Joined: Dec 07, 2001
Posts: 23
Thank you!
 
 
subject: FileReader issues
 
Similar Threads
Options on Opening Files
File
Collections.shuffle problem
Writing a Char Array to a tab delimited file
How do I read and write a binary file?