The class Exception, and hence also all its subclasses, have a method getMessage(), which allows one to extract the string associated to the exception.
Example:
try { ... } catch (NumberFormatException e) { System.out.println("Catched NumberFormatException"); System.out.println(e.getMessage()); } catch (IOException e) { System.out.println("Catched IOException"); System.out.println(e.getMessage()); }