I am new to Java and I want to know when an IOException
occurs and what is it actually. I also came across a point that whenever we use BufferedReader
class to read input from console the code should be kept within try
block and we should have a catch
block that handles the IOException
why is that so. Can someone help me ?
Asked
Active
Viewed 1,179 times
-5

Paul Vargas
- 41,222
- 15
- 102
- 148

darsha
- 61
- 1
- 9
-
2Have you seriously searched this thing on Google? – Rohit Jain Oct 27 '12 at 14:40
-
4_"Signals that an I/O exception of some sort has occurred. This class is the general class of exceptions produced by failed or interrupted I/O operations."_ http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html – Matt Ball Oct 27 '12 at 14:40
-
Also: http://docs.oracle.com/javase/tutorial/essential/exceptions/ – millimoose Oct 27 '12 at 14:42
-
@rohit yes i have searched. but i couldn get the concept behind the BufferedReader class. – darsha Oct 27 '12 at 14:44
-
1@darsha. How about the documentation itself? – Rohit Jain Oct 27 '12 at 14:45
1 Answers
2
The IOException is part of the interface. Errors usally occur when a file is not present, the disk is full, you are missing reading or writing privledges or you have network connectivity issues.
Depending on the implementation it might as well throw no errors at all even though its still declared in the interface.

Udo Held
- 12,314
- 11
- 67
- 93
-
Broadly speaking, whenever you interact your code through some I/O, you need to handle IOException. – Rohit Jain Oct 27 '12 at 14:42
-
but why don't we handle ioexception when we use Scanner class to read input from console – darsha Oct 27 '12 at 14:49