Skip to content

Tag: exception

Exception handling with Consumer functions in Java 8

This code gives me a compile error on the line processBatch(batch, this::backupMetacard); The process batch method wraps the consumer in a try/catch block, but Java will not compile the call. Answer The problem is that in the following snippet, the method backupMetacard declares to throw the checked IOExcepti…

How to ignore Exceptions in Java

I have the following code: I would like to execute: test.setSomething2(0); even if test.setSomething(0) (the line above it) throws an exception. Is there a way to do this OTHER than: I have a lot of test.setSomething’s in a row and all of them could throw Exceptions. If they do, I just want to skip that…

Java checked exceptions

I’m trying to understand checked exceptions in Java and have the following query. Is the following correct: If a method has the potential to throw a checked exception, of any type, that exception must either be declared using the throws keyword, or caught by the respective method. If the above is correc…