Close opened resources

- Add BufferedReader instantiation into try-with-resources statement
- Close scanner that was opened
- Create utility class to format a caught exception
This commit is contained in:
ljacqu
2015-11-25 22:51:30 +01:00
parent 5f9ba208de
commit c83e983dea
4 changed files with 40 additions and 11 deletions
@@ -107,4 +107,15 @@ public class StringUtils {
// Return the result as a string
return stringWriter.toString();
}
/**
* Format the information from a Throwable as string, retaining the type and its message.
*
* @param th The throwable to process
*
* @return String with the type of the Throwable and its message, e.g. "[IOException]: Could not open stream"
*/
public static String formatException(Throwable th) {
return "[" + th.getClass().getSimpleName() + "]: " + th.getMessage();
}
}