code: public static String[] render(final Throwable throwable) {
  
          StringWriter sw = new StringWriter();
          PrintWriter pw = new PrintWriter(sw);
          try {
              throwable.printStackTrace(pw);
          } catch (RuntimeException ex) {
              // nothing to do
          }
          pw.flush();
          LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
          ArrayList<String> lines = new ArrayList<>();
          try {
              String line = reader.readLine();
              while (line != null) {
                  lines.add(line);
                  line = reader.readLine();
              }
          } catch (IOException ex) {
              if (ex instanceof InterruptedIOException) {
                  Thread.currentThread().interrupt();
              }
              lines.add(ex.toString());
          }
          //String[] tempRep = new String[lines.size()];
          return lines.toArray(new String[0]);
      }
docs: Render throwable using Throwable.printStackTrace.
  <p>This code copy from "org.apache.log4j.DefaultThrowableRenderer.render(Throwable throwable)"</p>
  @param throwable throwable, may not be null.
  @return string representation.