Java Code Examples for java.io.PrintStream#equals()
The following examples show how to use
java.io.PrintStream#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteStatistics.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Boolean call() throws Exception { if (COLLECT_STATISTICS) { while (!stopAction()) { } PrintStream output = getOutput("totalTraffic"); // NOI18N try { trafficCounters.dump(output); // NOI18N } finally { if (!output.equals(System.out)) { output.close(); } } } return true; }
Example 2
Source File: Diagnostic.java From rtg-tools with BSD 2-Clause "Simplified" License | 6 votes |
/** * Write a throwable to the log stream. If writing to the log stream fails * and the log stream differs from <code>System.err</code>, then an attempt * is made to redirect the message to <code>System.err</code>. * * @param t throwable to write */ public static synchronized void userLog(final Throwable t) { final PrintStream log = getLogStream(); if (log != null) { t.printStackTrace(log); log.flush(); if (log.checkError()) { // The call to checkError forces a flush and returns true if the stream // is in an unusable state. This should not happen in ordinary usage, // but could happen if for example logging is going to a file and the // disk runs out of space. Therefore, if the current logging stream is // not System.err, we make an effort to redirect the log message to // that stream. if (!log.equals(System.err)) { if (!sLogRedirect) { sLogRedirect = true; System.err.println(now() + "Logging problem: redirecting logging to System.err."); } t.printStackTrace(System.err); System.err.flush(); } } } }
Example 3
Source File: RemoteStatistics.java From netbeans with Apache License 2.0 | 5 votes |
static boolean stopAction() { RemoteMeasurementsRef stopped = currentStatRef.getAndSet(unnamed); PrintStream output = getOutput(stopped.name); try { stopped.stat.dump(output); } finally { if (!output.equals(System.out)) { output.close(); } } return unnamed.equals(stopped); }
Example 4
Source File: Diagnostic.java From rtg-tools with BSD 2-Clause "Simplified" License | 5 votes |
/** * Write a message to the log stream. If writing to the log stream fails * and the log stream differs from <code>System.err</code>, then an attempt * is made to redirect the message to <code>System.err</code>. * * @param message to write * @param prefix a prefix to include before the message */ private static synchronized void userLog(final String message, final String prefix) { final PrintStream log = getLogStream(); if (log != null) { log.println(now() + prefix + message); final long currentTimeMillis = System.currentTimeMillis(); if (currentTimeMillis - sLastFlushTime > FLUSH_INTERVAL) { log.flush(); sLastFlushTime = currentTimeMillis; } if (log.checkError()) { // The call to checkError forces a flush and returns true if the stream // is in an unusable state. This should not happen in ordinary usage, // but could happen if for example logging is going to a file and the // disk runs out of space. Therefore, if the current logging stream is // not System.err, we make an effort to redirect the log message to // that stream. if (!log.equals(System.err)) { if (!sLogRedirect) { sLogRedirect = true; System.err.println("Logging problem: redirecting logging to System.err."); setLogStream(System.err); } System.err.println(now() + message); System.err.flush(); } } } }