Help with a java.io.IOException

/*

input : MemoryAccess - to load process into the disk

output : true if file opened, flase if fails

purpose : to open a file and read in the processes

code sourse: http://javaalmanac.com/egs/java.io/ReadLinesFromFile.html

*/

public boolean openFile(MemoryAccess ma)

{

Process p;

String file, inputString;

char name = ' ';

int mem = 0, quantum = 0, numProc;

char[] charArray;

//Ask user for file name

System.out.print("Enter file name:");

BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ));

file = stdin.readLine();

//We are writing this code under the assumption that the memory column(in small.dat) is formated to 2 spa\

ces

//and all other columns are one space.

try {

BufferedReader in = new BufferedReader(new FileReader(file));

numProc = new Integer(in.readLine()).intValue();

while ((inputString = in.readLine()) != null)

{

charArray = inputString.toCharArray();

name = charArray[0];

if((charArray[2] != ' ') && (charArray[3] != ' '))

{

mem = ((int)(charArray[2] * 10) + (int)charArray[3]);

}

else if(charArray[2] != ' ')

{

mem = charArray[2];

}

else

{

mem = charArray[3];

}

quantum = (int)charArray[5];

}

System.out.print(name + " ");

System.out.print(mem + " ");

System.out.println(quantum);

in.close();

return true;

} catch (IOException e)

{

return false;

}

}

Pwnix.java:67: unreported exception java.io.IOException; must be caught or declared to be thrown

file = stdin.readLine();

^

1 error

That is my code and my error, I can't figure out what's wrong.

[1847 byte] By [sadman64a] at [2007-10-2 15:59:24]
# 1

>

> Pwnix.java:67: unreported exception

> java.io.IOException; must be caught or declared to be

> thrown

> file = stdin.readLine();

> ^

> 1 error

>

> http://forum.java.sun.com/help.jspa?sec=formatting

> http://forum.java.sun.com/help.jspa?sec=formatting

> That is my code and my error, I can't figure out

> what's wrong.http://forum.java.sun.com/help.jspa?sec=formatting

Please use the code tags around your code samples. It is much easier to read.

http://forum.java.sun.com/help.jspa?sec=formatting

The error message you see indicates that the readLine() method could throw an IOException.Therefore, you must either place that method call inside a try block, or declare to throw the IOException from your own method where the call to readLine is made.

nantucketa at 2007-7-13 16:25:38 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...