Here you can find the source of exceptionToString(TransformerException exception, boolean showSystemId)
public static String exceptionToString(TransformerException exception, boolean showSystemId)
//package com.java2s; //License from project: Apache License import org.xml.sax.SAXParseException; import javax.xml.transform.SourceLocator; import javax.xml.transform.TransformerException; public class Main { public static String exceptionToString(TransformerException exception, boolean showSystemId) { StringBuffer message = new StringBuffer(20); if (exception.getLocator() != null) { SourceLocator locator = exception.getLocator(); appendLocation(message, showSystemId ? locator.getSystemId() : null, locator.getLineNumber(), locator.getColumnNumber()); }/* ww w .jav a 2 s. c o m*/ message.append(exception.getMessage()); return message.toString(); } public static String exceptionToString(SAXParseException exception, boolean showSystemId) { StringBuffer message = new StringBuffer(20); appendLocation(message, showSystemId ? exception.getSystemId() : null, exception.getLineNumber(), exception.getColumnNumber()); message.append(exception.getMessage()); return message.toString(); } private static void appendLocation(StringBuffer message, String systemId, int lineNum, int colNum) { if (systemId != null) message.append(systemId); String line = ""; String column = ""; if (lineNum > 0) line = "line#: " + lineNum; if (colNum > 0) column = "col#: " + colNum; if (line.length() > 0 && systemId != null) message.append(", "); message.append(line); if (column.length() > 0) message.append(", "); message.append(column); if (systemId != null || lineNum > 0 || colNum > 0) message.append("; "); } }