Example usage for java.io PrintStream flush

List of usage examples for java.io PrintStream flush

Introduction

In this page you can find the example usage for java.io PrintStream flush.

Prototype

public void flush() 

Source Link

Document

Flushes the stream.

Usage

From source file:com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJobAlertImpl.java

protected static void attachException(MimeMessageHelper messageHelper, ExceptionInfo exceptionInfo)
        throws MessagingException {
    Throwable exception = exceptionInfo.getException();
    if (exception == null) {
        return;/*from  w w w .  j  av a2 s  .  com*/
    }

    ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
    PrintStream printOut = new PrintStream(bufOut);
    exception.printStackTrace(printOut);
    printOut.flush();

    String attachmentName = "exception_" + System.identityHashCode(exception) + ".txt";
    messageHelper.addAttachment(attachmentName, new ByteArrayResource(bufOut.toByteArray()));
}

From source file:org.wso2.andes.tools.security.Passwd.java

private static void output(String user, byte[] encoded) throws IOException {

    //        File passwdFile = new File("qpid.passwd");

    PrintStream ps = new PrintStream(System.out);

    user += ":";//from ww w .j  a va 2 s  .c  o m
    ps.write(user.getBytes("utf-8"));

    for (byte b : encoded) {
        ps.write(b);
    }

    ps.println();

    ps.flush();
    ps.close();
}

From source file:net.heroicefforts.viable.android.rep.it.Main.java

private static final String toString(Throwable t) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    t.printStackTrace(ps);//  w  ww .java  2s. co  m
    ps.flush();
    return baos.toString();
}

From source file:com.zenoss.zenpacks.zenjmx.call.Utility.java

public static void debugStack(Throwable e) {
    if (!_logger.isDebugEnabled())
        return;//from w w  w .  j a  va  2  s  . com
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    e.printStackTrace(ps);
    ps.flush();
    String stackTrace = baos.toString();
    _logger.debug(e.getMessage() + "\n" + stackTrace);
}

From source file:de.tynne.benchmarksuite.Main.java

private static void listBenchmarks(BenchmarkProducer benchmarkProducer, PrintStream ps) {
    benchmarkProducer.get().stream().forEach((b) -> ps.printf("%s: %s\n", b.getId(), b.getName()));
    ps.flush();
}

From source file:com.sap.prd.mobile.ios.mios.FileUtilsTest.java

private static boolean checkForSymbolicLink(final File f) throws IOException {

    ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
    PrintStream stream = new PrintStream(byteOs);

    try {/* w  ww  .ja va2 s . co m*/
        Forker.forkProcess(stream, null, "ls", "-l", f.getAbsolutePath());
        stream.flush();
        return byteOs.toString().startsWith("l");
    } finally {
        IOUtils.closeQuietly(stream);
    }
}

From source file:org.apache.hadoop.hive.common.log.InPlaceUpdate.java

public static void rePositionCursor(PrintStream ps) {
    ps.print(ansi().cursorUp(0).toString());
    ps.flush();
}

From source file:Main.java

/**
 * Recursively walks the DOM tree starting at the given <CODE>Node</CODE>
 * printing the gory details of its construction to the indicated
 * <CODE>PrintStream</CODE>.
 * //from  w w  w.j  a v  a 2s .  com
 * @param   out            The <CODE>PrintStream</CODE> for output.
 * @param    node         The <CODE>Node</CODE> to start the dump at.
 * @since   TFP 1.0
 */
public static void dump(PrintStream out, final Node node) {
    doDump(out, node, 0);
    out.flush();
}

From source file:com.moss.appsnap.keeper.HandyTool.java

private static void printStackTrace(Throwable t, StringBuilder text) {
    try {//from  w ww  .  j  av  a2 s.  c  om
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream s = new PrintStream(out);
        t.printStackTrace(s);
        s.flush();
        out.close();
        text.append(new String(out.toByteArray()));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.apache.hadoop.hive.common.log.InPlaceUpdate.java

public static void reprintLine(PrintStream out, String line) {
    out.print(ansi().eraseLine(Ansi.Erase.ALL).a(line).a('\n').toString());
    out.flush();
}