views:

68

answers:

2

why we use 'Throws IOException' in java File handling. i mean what is the purpose of using these two words in File handling?? Please help...

+3  A: 

You are probably referring to checked exceptions. They are used to indicate that a method could potentially throw one of the listed exceptions so that the callers need to explicitly catch them or be marked with the same exceptions list.

Darin Dimitrov
+2  A: 

The throws word means that the code could enter an error state, the IOExeption word describes the error state.

This means that you will have to put any method that throws IOExcepion into a try ... catch block where you can write code to make your program respond to the error state appropriately.

Edwin Buck