[Java] Exception stacktrace in String wandeln

/**
 * prints a stacktrace to a string
 * @param e the exception, those stacktrace to be printed
 * @return stacktrace
 */
public static String StackTraceToString(Exception e)
{
    String NEW_LINE = System.getProperty("line.separator");

    StackTraceElement[] stack = e.getStackTrace();
    
    String trace = "";
    
    for (StackTraceElement line : stack)
    {
        trace += line.toString() + NEW_LINE;
    }
    
    return trace;
}