Saving Files

I am very new to java programming and i am having difficulties properly implimenting a method which saves text from a text area as a file. Here is my current code, it apparently thinks i haven't dealt with an IOException error.

File aFile = null;

String aContents;

int result = fc.showSaveDialog(this);

if (result == fc.APPROVE_OPTION) {

Writer output = null;

try {

output = new BufferedWriter( new FileWriter(aFile) );

output.write( jTextArea1.getText());

} catch (IOException err){

err.printStackTrace();

} finally {

if (!aFile.canWrite()) {

throw new IllegalArgumentException("This File is ******" + aFile);

}

if (output != null) output.close();

}

}

}

[771 byte] By [Lennoxa] at [2007-11-26 16:52:37]
# 1
All methods which can throw an IOException must be within try/catch. close can throw IOException.KajPs. Another option is to declare the method as throwing IOException.
kajbja at 2007-7-8 23:20:18 > top of Java-index,Java Essentials,New To Java...
# 2
thank you
Lennoxa at 2007-7-8 23:20:18 > top of Java-index,Java Essentials,New To Java...