Throw Exception?

I am attempting to open a file, read its contents and pass them into an array:

//Opens Numbers File

FileReader freader = new FileReader("Numbers.txt");

BufferedReader inputFile = new BufferedReader(freader);

//Reads the file contents into array.

str = inputFile.readLine();

while (str != null && i < 20)

{

numArray = Double.parseDouble(str);

i++;

str=inputFile.readLine();

}

//Closes the file

inputFile.close();

When I try to compile that I get the following errors:

NumberAnalysis.java:20: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown

FileReader freader = new FileReader("Numbers.txt");

^

NumberAnalysis.java:24: unreported exception java.io.IOException; must be caught or declared to be thrown

str = inputFile.readLine();

^

NumberAnalysis.java:29: unreported exception java.io.IOException; must be caught or declared to be thrown

str=inputFile.readLine();

^

NumberAnalysis.java:33: unreported exception java.io.IOException; must be caught or declared to be thrown

inputFile.close();

^

4 errors

Any ideas in what I am doing wrong? Thank you.

[1286 byte] By [tarhill76a] at [2007-11-26 21:56:27]
# 1
A FileNotFoundException means the file you tried to open wasn't found. Make sure you pass the file with the correct path.
hunter9000a at 2007-7-10 3:52:58 > top of Java-index,Java Essentials,New To Java...
# 2
The file is in the same directory as the java file I am compiling. Do I still have to specify the full path?
tarhill76a at 2007-7-10 3:52:58 > top of Java-index,Java Essentials,New To Java...
# 3

The methods you're invoking MAY throw exceptions. Put your code in a try-catch block, i.e.

try

{

// Code that may throw an exception here

}

catch (IOException ioe)

{

// Exception handling here

}

#

duckbilla at 2007-7-10 3:52:58 > top of Java-index,Java Essentials,New To Java...
# 4
> The file is in the same directory as the java file I> am compiling. Do I still have to specify the full> path?You don't have to, but it couldn't hurt.
hunter9000a at 2007-7-10 3:52:58 > top of Java-index,Java Essentials,New To Java...
# 5

Read up on the concepts "current directory" and "working directory" and "current working directory" and their effect on relative path names. (Actually you should have been taught that before you were taught programming.) Don't assume that "the same directory as the java file I am compiling" is the same thing.

DrClapa at 2007-7-10 3:52:58 > top of Java-index,Java Essentials,New To Java...