you shouldn't catch these two exceptions only to print the stack trace. the java runtime will already do that for you. so remove the outer try catch and let the exception be caught by the runtime.