List of usage examples for java.io PrintStream flush
public void flush()
From source file:org.moe.gradle.remote.AbstractServerTask.java
private int printTaskMarker(PrintStream stream, TermColor color, String message) { final String sep = StringUtils.rightPad("", message.length() + 1, "="); stream.println("\n" + color.toString() + sep + "\n" + message + "\n" + sep + FM_RES_ALL + "\n"); stream.flush(); return sep.length(); }
From source file:org.matheclipse.commons.parser.util.Console.java
/** * prints a prompt on the console but doesn't print a newline * // ww w . j ava2s . co m * @param out * @param prompt * the prompt string to display * */ public void printPrompt(final PrintStream out, final String prompt) { out.print(prompt); out.flush(); }
From source file:com.openkm.servlet.admin.UnitTestingServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("doGet({}, {})", request, response); String test = WebUtils.getString(request, "test"); response.setContentType("text/html; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); OutputStream os = response.getOutputStream(); PrintStream ps = new PrintStream(os); header(ps, "Unit testing", breadcrumb); ps.flush(); RunListener listener = new CustomListener(ps); JUnitCore junit = new JUnitCore(); junit.addListener(listener);// www .j ava2 s . co m if (test != null && !test.isEmpty()) { try { Class<?> clazz = Class.forName(test); ps.println("<b>" + clazz.getCanonicalName() + "</b><br/>"); ps.flush(); ps.println("<pre>"); ps.flush(); junit.run(clazz); ps.println("</pre>"); ps.flush(); } catch (ClassNotFoundException e) { warn(ps, e.getMessage()); } } else { for (Class<?> clazz : new Reflections("com.openkm.test.api").getSubTypesOf(TestCase.class)) { ps.println("<a style=\"color: black; font-weight:bold;\" href=\"UnitTesting?test=" + clazz.getCanonicalName() + "\">" + clazz.getCanonicalName() + "</a><br/>"); ps.flush(); ps.println("<pre>"); ps.flush(); junit.run(clazz); ps.println("</pre>"); ps.flush(); } } ps.println( "<span style=\"color: blue; font-weight:bold;\">>>> End Of Unit Testing <<<</span>"); footer(ps); ps.flush(); IOUtils.closeQuietly(ps); IOUtils.closeQuietly(os); }
From source file:com.xpn.xwiki.store.XWikiBatcherStats.java
public void printSQLList(PrintStream out) { out.println("SQL: number of queries " + sqlList.size()); for (int i = 0; i < sqlList.size(); i++) { out.println("SQL: " + sqlList.get(i)); }//from w w w. ja v a 2s . c o m out.flush(); }
From source file:com.adaptris.http.HttpRequest.java
/** Write the request line to the supplied outputstream. * @param out the outputstream/*w w w. j a va 2s. c om*/ * @throws HttpException on error. * @see DataTransfer#writeTo(OutputStream) */ public void writeTo(OutputStream out) throws HttpException { try { logR.trace("Writing Request:- " + toString()); PrintStream p = new PrintStream(out); p.print(toString()); p.print(Http.CRLF); p.flush(); } catch (Exception e) { throw new HttpException(e); } }
From source file:net.extemporal.test.Main.java
@Command public void localTest(String m1, String m2) { SimpleTestPlatform hakuna = new SimpleTestPlatform("Hakuna"), matata = new SimpleTestPlatform("Matata"); PrintStream w = System.out; w.println("Local test commencing"); if (m1 != null && m1.trim().length() > 0) { w.println("Hakuna sending message '" + m1 + "' to Matata"); hakuna.sendMessage("Matata", m1); w.flush(); }//from w w w .j ava2s . c o m if (m2 != null && m2.trim().length() > 0) { w.println("Matata sending message '" + m2 + "' to Hakuna"); matata.sendMessage("Hakuna", m2); w.flush(); } hakuna.shutdown(); matata.shutdown(); w.println("Local test ended!"); }
From source file:de.tudarmstadt.lt.ltbot.writer.PlainTextDocumentWriter.java
protected PrintStream openPrintToFileStream(File outputfile) throws IOException { OutputStream os = new FileOutputStream(outputfile, true); if (getFilenameFormat().endsWith(".gz")) { os = new GZIPOutputStream(os); //{{ def.setLevel(Deflater.BEST_COMPRESSION); }}; }/*from w w w . java 2 s. c om*/ PrintStream p = new PrintStream(os); p.flush(); return p; }
From source file:org.duracloud.account.monitor.MonitorsDriver.java
/** * This method invokes the .run() method on the provided arg target. * * @param target to monitor/* w w w. ja v a2 s . c om*/ */ public void monitor(Monitor target) { log.info("starting monitor: {}", target); try { target.getMonitorDriver(props, configService).run(); } catch (Exception e) { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream error = new PrintStream(out); error.println("Error in MonitorsDriver: " + e.getMessage()); e.printStackTrace(error); error.flush(); IOUtils.closeQuietly(out); String msg = new String(out.toByteArray()); log.error(msg); sendEmail("Management Console Monitors Error", msg); } }
From source file:ductive.console.shell.EmbeddedGroovyShell.java
@Override public void execute(InteractiveTerminal terminal, TerminalUser user) throws IOException { Binding binding = new Binding(); if (context != null) for (Entry<String, Object> e : context.entrySet()) binding.setVariable(e.getKey(), e.getValue()); CompilerConfiguration config = new CompilerConfiguration(); binding.setProperty("out", new PrintStream(terminal.output(), true)); // binding.setProperty("in",new BufferedReader(new InputStreamReader(terminal.input()))); FIXME: GroovyInterpreter interpreter = new GroovyInterpreter(binding, config); try (ShellHistory history = historyProvider.history(HISTORY_KEY)) { final AtomicBoolean pending = new AtomicBoolean(false); ShellSettings settings = new StaticShellSettings(new Provider<Ansi>() { @Override/*from w w w . j ava 2s . com*/ public Ansi get() { return pending.get() ? pendingPrompt : standardPrompt; } }, new ReflectionCompleter(interpreter), history); terminal.updateSettings(settings); while (true) { pending.set(false); final String code; try { code = new CodeReader(terminal, pending).read(); } catch (UserInterruptException e) { continue; } if (code == null) { terminal.println(""); break; } if (StringUtils.isBlank(code)) continue; try { Object result = interpreter.interpret(code); terminal.println(String.format(resultMarker.toString(), result)); } catch (Throwable e) { // Unroll invoker exceptions if (e instanceof InvokerInvocationException) { e = e.getCause(); } PrintStream ps = new PrintStream(terminal.error()); e.printStackTrace(ps); ps.flush(); } } } }
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogGreaterThanBuffer() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.INFO)); StringBuffer sb = new StringBuffer(); while (sb.length() < 2048) { sb.append(TEXT);/* ww w.j av a 2 s . c o m*/ } out.println(sb.toString()); out.flush(); out.close(); }