开发者

use of "throws IOException" in java file handling [closed]

开发者 https://www.devze.com 2023-01-05 08:30 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

开发者_运维技巧

Closed 6 years ago.

Improve this question

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...


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消