@Test public void testGetStackTraceAsString() { Exception exception = new Exception("Test exception"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw); assertEquals(sw.toString(), StringUtils.getStackTraceAsString(exception)); try { sw.close(); } catch (IOException e) { e.printStackTrace(); } pw.close(); exception = new Exception(); sw = new StringWriter(); pw = new PrintWriter(sw); exception.printStackTrace(pw); assertEquals(sw.toString(), StringUtils.getStackTraceAsString(exception)); try { sw.close(); } catch (IOException e) { e.printStackTrace(); } pw.close(); assertEquals("", StringUtils.getStackTraceAsString(null)); }
public static String getStackTraceAsString(Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); final String stackTraceAsString = sw.toString(); try { sw.close(); } catch (IOException e) { e.printStackTrace(); } pw.close(); return stackTraceAsString; } else { return Constants.EMPTY_STRING; } }
StringUtils { public static String getStackTraceAsString(Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); final String stackTraceAsString = sw.toString(); try { sw.close(); } catch (IOException e) { e.printStackTrace(); } pw.close(); return stackTraceAsString; } else { return Constants.EMPTY_STRING; } } }
StringUtils { public static String getStackTraceAsString(Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); final String stackTraceAsString = sw.toString(); try { sw.close(); } catch (IOException e) { e.printStackTrace(); } pw.close(); return stackTraceAsString; } else { return Constants.EMPTY_STRING; } }  }
StringUtils { public static String getStackTraceAsString(Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); final String stackTraceAsString = sw.toString(); try { sw.close(); } catch (IOException e) { e.printStackTrace(); } pw.close(); return stackTraceAsString; } else { return Constants.EMPTY_STRING; } }  static boolean toBoolean(String value, boolean defaultValue); static int toInt(String value, int defaultValue); static String toNotEmptyString(String value, String defaultValue); static String toNewline(String value); static Path toPath(String value, Path defaultValue); static String getStackTraceAsString(Throwable t); static int validatePortNumber(String portStringValue, String portInputName); }
StringUtils { public static String getStackTraceAsString(Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); final String stackTraceAsString = sw.toString(); try { sw.close(); } catch (IOException e) { e.printStackTrace(); } pw.close(); return stackTraceAsString; } else { return Constants.EMPTY_STRING; } }  static boolean toBoolean(String value, boolean defaultValue); static int toInt(String value, int defaultValue); static String toNotEmptyString(String value, String defaultValue); static String toNewline(String value); static Path toPath(String value, Path defaultValue); static String getStackTraceAsString(Throwable t); static int validatePortNumber(String portStringValue, String portInputName); static final String DEFAULT_DELIMITER; static final String DIGITS_REGEX; }