List of usage examples for java.io PrintStream flush
public void flush()
From source file:ductive.console.shell.EmbeddedAppShell.java
private Integer execute(CmdParser cmdParser, InteractiveTerminal terminal, ShellHistory history, TerminalUser user) throws IOException { final CommandLine line; try {//from www . ja va 2 s. c o m String command = terminal.readLine(); if (command == null) return 0; if (StringUtils.isBlank(command)) return null; line = cmdParser.parse(command); } catch (NoMatchException e) { terminal.errorln(e.getMessage()); return null; } try { commandInvoker.execute(new CommandContext(terminal, user), line); } catch (UserInterruptException e) { } catch (Throwable e) { // Unroll invoker exceptions if (e.getClass().getCanonicalName().equals("org.codehaus.groovy.runtime.InvokerInvocationException")) { e = e.getCause(); } PrintStream ps = new PrintStream(terminal.error()); e.printStackTrace(ps); ps.flush(); } return null; }
From source file:com.adaptris.core.socket.SimpleProtocol.java
/** * @see com.adaptris.core.socket.Protocol#receiveDocumentError() */// w w w . java 2s . c o m public void receiveDocumentError() throws IOException, IllegalStateException { PrintStream out = new PrintStream(socket.getOutputStream(), true); out.print("500\r\n"); out.flush(); }
From source file:com.adaptris.core.socket.SimpleProtocol.java
/** * @see com.adaptris.core.socket.Protocol#receiveDocumentSuccess() *///from w w w. j a v a 2 s .co m public void receiveDocumentSuccess() throws IOException, IllegalStateException { PrintStream out = new PrintStream(socket.getOutputStream(), true); out.print("200\r\n"); out.flush(); }
From source file:brooklyn.util.stream.ThreadLocalPrintStream.java
public PrintStream clearThreadLocalPrintStream() { PrintStream old = customStream.get(); customStream.remove();/*from www . ja v a 2 s. c om*/ if (old != null) old.flush(); return old; }
From source file:org.duracloud.account.monitor.duplication.DuplicationMonitorDriver.java
@Override public void run() { log.info("starting monitor"); DuplicationReport report;// w w w .ja v a2 s .c om try { report = duplicationMonitor.monitorDuplication(); if (report.hasIssues()) { sendEmail("DuraCloud Duplication Monitor discovered issues!", report.toString()); } } catch (Exception e) { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream error = new PrintStream(out); error.println("Error in DuplicationMonitor: " + e.getMessage()); e.printStackTrace(error); error.flush(); IOUtils.closeQuietly(out); String msg = new String(out.toByteArray()); log.error(msg); sendEmail("Duplication Monitor Error", msg); } }
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogTrace() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream("TRACE")); out.println(TEXT);//from w w w. j a v a 2s . c om out.flush(); out.close(); }
From source file:org.apache.karaf.shell.tabletest.ShellTableTest.java
@Test public void testGrow() { ShellTable table = new ShellTable().size(10); table.column(new Col("1")); table.column(new Col("2")); table.addRow().addContent("1", "2"); StringWriter writer = new StringWriter(); PrintStream out = new PrintStream(new WriterOutputStream(writer)); table.print(out, true);//from w ww. j av a 2 s.com out.flush(); String expected = "1 | 2\n" + "----------\n" + "1 | 2\n"; Assert.assertEquals(expected, getString(writer)); }
From source file:org.apache.karaf.shell.tabletest.ShellTableTest.java
@Test public void testNoFormat() { ShellTable table = new ShellTable(); table.column(new Col("first")); table.column(new Col("second")); table.addRow().addContent("first column", "second column"); StringWriter writer = new StringWriter(); PrintStream out = new PrintStream(new WriterOutputStream(writer)); table.print(out, false);/* w ww .ja va 2s . co m*/ out.flush(); String expected = "first column\tsecond column\n"; Assert.assertEquals(expected, getString(writer)); }
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogInfo() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.INFO)); out.println(TEXT);/* w w w .j a v a 2 s. c o m*/ out.flush(); out.close(); }
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogWarn() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.WARN)); out.println(TEXT);// ww w . j av a 2 s .c om out.flush(); out.close(); }