Class InterruptedIOException in Java

Class InterruptedIOException in Java

InterruptedIOException is another popular built-in exception classes in java and is thrown from an application to indicate that an input-output operation has been interrupted. The bytesTransferred variable contains the number of bytes read or written before the operation was interrupted.

This can occur when a thread is waiting for data to become available for a PipedInputStream or PipedReader to read.

Ads code goes here

It can also occur when a thread is waiting for buffer space to become available for a PipedOutputStream or PipedWriter to write to. If the thread’s interrupt() method is called while the thread is waiting, the read() or write() method in question throws an InterruptedIOException.

The structure of the class InterruptedIOException is given below:

public class java.io.InterruptedIOException extends java.io.IOException{
//Member elements:
public int bytesTransferred;
//constructor
public InterruptedIOException();
public InterruptedIOException(String message);
}

The details of the class structure are given as:

public int bytesTransferred;

public int bytesTransferred tells the number of bytes that had been transferred before the interruption. in other words it tells us how many bytes has been transferred as part of the IO-operation before it was interrupted.

public InterruptedIOException();

public InterruptedIOException() constrcutor constructs an empty InterruptedIOException object that is an object with no message specified.

public InterruptedIOException(String message);

public InterruptedIOException(String message) constrcutor constructs an InterruptedIOException object with the message specified.
Parameter
message-The detail message.
The class InterruptedIOException also inherits methods from class Object and Throwable.

From Object classFrom Throwable class
clone()fillInStackTrace()
getClass()getMessage()
notify()printStackTrace()
wait()printStackTrace(PrintWriter)
wait(long, int)getLocalizedMessage()
wait(long)printStackTrace(PrintStream)
equals(Object)
toString()
finalize()
hashCode()
notifyAll()
READ  Variables in Java

Share and Enjoy !

Leave a Comment

Your email address will not be published. Required fields are marked *