Here you can find the source of diagnosticToString(final Diagnostic extends JavaFileObject> diagnostic, boolean usingAnomsgtxt)
public static String diagnosticToString(final Diagnostic<? extends JavaFileObject> diagnostic, boolean usingAnomsgtxt)
//package com.java2s; //License from project: GNU General Public License import javax.tools.Diagnostic; import javax.tools.JavaFileObject; public class Main { public static String diagnosticToString(final Diagnostic<? extends JavaFileObject> diagnostic, boolean usingAnomsgtxt) { String result = diagnostic.toString().trim(); // suppress Xlint warnings if (result.contains("uses unchecked or unsafe operations.") || result.contains("Recompile with -Xlint:unchecked for details.") || result.endsWith(" declares unsafe vararg methods.") || result.contains("Recompile with -Xlint:varargs for details.")) { return null; }/*from www . j ava 2 s . co m*/ if (usingAnomsgtxt) { // Lines with "unexpected Throwable" are stack traces // and should be printed in full. if (!result.contains("unexpected Throwable")) { String firstLine; if (result.contains("\n")) { firstLine = result.substring(0, result.indexOf('\n')); } else { firstLine = result; } if (firstLine.contains(".java:")) { firstLine = firstLine.substring(firstLine.indexOf(".java:") + 5).trim(); } result = firstLine; } } return result; } }