<<< catching IOException example | Index | throw syntax >>> |
A method that throws the IOException
public static int getRecordCount3() throws IOException
{
long length = getFileLength(); // may throw
// IOException
int recordCount = (int) ( length / RECORD_SIZE );
return recordCount;
}
Compiler error generated if you don't catch or throw a checked exception
C:\java\netbeans\src\ProductApp.java:12: error: unreported exception IOException; must be caught or declared to be thrown getRecordCount()
<<< catching IOException example | Index | throw syntax >>> |