![]() |
VOOZH | about |
The class StreamCorruptedException of ObjectStreamException is an exception thrown when control information that was read from an object stream violates internal consistency checks. It will create a StreamCorruptedException and list a reason why the exception was thrown. If no parameters are passed in the constructor, then it will create a StreamCorruptedException and list no reason why the exception was thrown.
Syntax:
public StreamCorruptedException(String reason)
Parameters: reason - “String” describing the reason for the exception
Example 1:
Output:
java.io.StreamCorruptedException: File format not recognised
Now dwelling on the second example where file format is recognized. It is as follows for which go through below sample note below prior to implementation.
Note: Make the C098.txt file in the same folder of the program and copy the following fragment as it is. It is an example corrupted file
C098.txt
’ sr Product L desct Ljava / lang / String; L priceq ~ L productIdq ~ xpt Bookt Rs .200t P001’ sr Product L desct Ljava / lang / String; L priceq ~ L productIdq ~ xpt Laptopt Rs .45, 500t P087
Example 2:
Output:
Stream Corrupted Exception Occurred