Linked Questions
27 questions linked to/from Can I catch multiple Java exceptions in the same catch clause?
129 votes
6 answers
193k views
Is it possible in Java to catch two exceptions in the same catch block? [duplicate]
I need to catch two exceptions because they require the same handling logic. I would like to do something like: catch (Exception e, ExtendsRuntimeException re) { // common logic to handle both ...
13 votes
1 answer
13k views
To combine two catch clasuses in the same [duplicate]
I have the following code: try { //do some } catch (NumberFormatException e) { return DynamicFilterErrorCode.INVALID_VALUE; } catch (ClassCastException e) { return DynamicFilterErrorCode....
2 votes
4 answers
3k views
java - Managing duplicate code in multiple catch blocks [duplicate]
I have the following code try { // code } catch (Exception1 e1) { if (condition) { //code } else { throw e1; } } catch (Exception2 ...
-1 votes
5 answers
6k views
How is multiple exception handling done in java? [duplicate]
i have below piece of code which in my spring boot applicatin. This piece of code does email validation, class EmailValidation { public static void validate(List<String> s){ try { ...
1 vote
3 answers
260 views
Is there any way to catch multiple Java exceptions in a single catch clause (OLD JAVA VERSIONS)? [duplicate]
I know it is a probable duplicate of this question. But the answer to that question includes the | inside the catch (..|..) which is unsupported in the earlier Java versions. I am bound to use an old ...
0 votes
2 answers
220 views
Java Try / Catch statement exception types [duplicate]
If I have a try/catch block which catches an IndexOutOfBounds exception, but in the same code, I want to access a file, is it possible to do a general excepction which could catch an IOException too? ...
0 votes
2 answers
505 views
What's the meaning of "java class |" computation [duplicate]
public void run() { final V value; try { value = getDone(future); } catch (ExecutionException e) { callback.onFailure(e.getCause()); return; } catch (...
77 votes
16 answers
70k views
Is it really that bad to catch a general exception?
Whilst analysing some legacy code with FXCop, it occurred to me is it really that bad to catch a general exception error within a try block or should you be looking for a specific exception. Thoughts ...
97 votes
8 answers
120k views
New features in java 7
What new features in java 7 is going to be implemented? And what are they doing now?
24 votes
3 answers
88k views
New features in JDK 1.6 and 1.7
I know JDK 1.5 pretty well. As we all know, besides new API (such as AtomicInteger, for example), there were major language changes such as providing support for generic, adding enum, prividing auto-...
15 votes
3 answers
22k views
java.lang.VerifyError: Stack map does not match the one at exception handler
Faced this java.lang.VerifyError with code snippet as below during JVM loading bytecode. try{ ----- } catch (NumberFormatException|CalculationException e) { } Here CalculationException is custom ...
2 votes
6 answers
2k views
How to handle all the java.net exceptions in a single catch block?
I am trying to handle the exceptions that are a part of the java.net package. I went through the documentation and I saw 12 exceptions belonging to that package, but I couldn't find the parent class ...
2 votes
3 answers
6k views
how to play audio file in android from internal memory of phone
I want to make sample to play an audio file in android ,i want to play music from internal memory of phone .how to give path please suggest. I am writing this,but facing java.io.IOException:prepare ...
1 vote
4 answers
3k views
Java - Write one method to handle all exceptions
im trying to handle exceptions on my code and at the same time without repeating it. I have lots of method on the "System" Class and i would prefer not to write "Try Catch" in all of them as i ...
0 votes
1 answer
3k views
How to catch two or more Exceptions in JAVA?
how can i catch 2 or more exception in same time ? Should i use trycatch-block for each all issue ? For example, i couldn t catch b.charAt() to "Null Pointer Exception" after ...