Re: exception
My apologies, the code for the throw was assumed. I've included it here.
Thanks
public void actionPerformed(ActionEvent e)
{
try
{
addingStudent();
}
catch (IOException x)
{
String name;
name = StudentTextField.getText();
FileWriter swriter = new FileWriter("c:\\studname.txt",true);
FileWriter gwriter = new FileWriter("c:\\grades.txt",true);
PrintWriter outputFile2 = new PrintWriter(gwriter);
PrintWriter outputFile= new PrintWriter(swriter);
outputFile.println(name);
outputFile2.println("0,0,0");
outputFile.close();
outputFile2.close();
StudentTextField.setText("");
}
"Eric Sosman" <esosman@ieee-dot-org.invalid> wrote in message
news:KrKdney7gd1EGNLanZ2dnUVZ_hisnZ2d@comcast.com...
Art Cummings wrote:
[...]
The error message I get.
X?StudentAddWindow.java:92: exception java.io.IOException is never
thrown in body of corresponding try statement
private class addButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{ String name;
} catch (IOException x)
[...]
Well, okay, why do you thing `String name;' is going
to throw an IOException? The whole inside of the try block
does nothing at all -- it declares a variable `name' that
can refer to String objects, but never uses it and never
does anything -- so there's no way an IOException can ever
be thrown. Why are you trying to catch something that
cannot exist?
--
Eric Sosman
esosman@ieee-dot-org.invalid