Hi all, Is there any particular reason why instantiating a new FileWriter throws an IOException while instantiating a new PrintWriter throws a FileNotFoundException?
edit: oh and also, why don't the close() and flush() methods throw an IOException in PrintWriter while they do in FileWriter and BufferedWriter ? [ December 16, 2008: Message edited by: jean-gobert de coster ]
I think FileWriter is low-level writer and designed very early of the java production, so developers would have decided to propagate the exception upto the use to handle explicitly, that's why flush(), close(), write() throws exception.
And PrintWriter is very high level writer, it is known for easy to use. That's why they would have handled these execeptions in the methods itself instead of propagating. I donot think there any big issue to design this way. I think first they propagated the exception, but after some time they could have found handling them will provide more cleaner API, so...
All IO methods have exception, but in some they are handled in them, in some they are thrown.