List of usage examples for java.io PrintStream flush
public void flush()
From source file:org.apache.karaf.shell.tabletest.ShellTableTest.java
@Test public void testNoFormatWithCustomSeparator() { ShellTable table = new ShellTable(); table.separator(";"); 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. j a v a 2 s. c o m out.flush(); String expected = "first column;second column\n"; Assert.assertEquals(expected, getString(writer)); }
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogDebug() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.DEBUG)); out.println(TEXT);/* ww w.j a v a2 s . c o m*/ out.flush(); out.close(); }
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogError() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.ERROR)); out.println(TEXT);/* w ww. ja v a2 s .c om*/ out.flush(); out.close(); }
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogFatal() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.FATAL)); out.println(TEXT);/*w w w. ja v a 2s . com*/ out.flush(); out.close(); }
From source file:org.apache.karaf.shell.tabletest.ShellTableTest.java
@Test public void testShrink() { ShellTable table = new ShellTable().size(10); table.column(new Col("1").maxSize(5)); table.column(new Col("2").alignRight()); table.addRow().addContent("quite long", "and here an even longer text"); StringWriter writer = new StringWriter(); PrintStream out = new PrintStream(new WriterOutputStream(writer)); table.print(out, true);/*from w w w . jav a 2 s. co m*/ out.flush(); String expected = // "1 | 2\n" // + "----------\n" // + "quite | a\n"; Assert.assertEquals(expected, getString(writer)); }
From source file:org.apache.karaf.shell.tabletest.ShellTableTest.java
@Test public void testTooSmall() { ShellTable table = new ShellTable().size(2); table.column(new Col("1").maxSize(5)); table.column(new Col("2").alignRight()); table.addRow().addContent("quite long", "and here an even longer text"); StringWriter writer = new StringWriter(); PrintStream out = new PrintStream(new WriterOutputStream(writer)); table.print(out, true);//from w ww . j ava 2 s .c om out.flush(); String expected = // "1 | \n" + // "--------\n" + // "quite | \n"; Assert.assertEquals(expected, getString(writer)); }
From source file:hudson.cli.CopyJobCommandTest.java
@Test public void copyBetweenFolders() throws Exception { MockFolder dir1 = j.createFolder("dir1"); MockFolder dir2 = j.createFolder("dir2"); FreeStyleProject p = dir1.createProject(FreeStyleProject.class, "p1"); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream outS = new PrintStream(out); int result = new CopyJobCommand().main(Arrays.asList("dir1/p1", "dir2/p2"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush(); assertEquals(out.toString(), 0, result); assertEquals("", out.toString()); assertNotNull(j.jenkins.getItemByFullName("dir2/p2")); // TODO test copying from/to root, or into nonexistent folder }
From source file:org.sonar.plugins.gosu.codenarc.printer.XMLPrinter.java
@Override public File printAll(File resultDir) throws Exception { File resultFile = setUpRulesFile(resultDir); PrintStream out = new PrintStream(resultFile, "UTF-8"); out.print(resultAsXML);//from w ww .j ava2 s. c o m out.flush(); out.close(); return resultFile; }
From source file:com.adaptris.core.socket.SimpleProtocol.java
/** * @see com.adaptris.core.socket.Protocol#sendDocument(byte[]) *//* w w w . j a va2 s . c o m*/ public void sendDocument(byte[] bytes) throws IOException { PrintStream out = new PrintStream(socket.getOutputStream(), true); out.print(new String(bytes) + "\r\n"); out.flush(); UnbufferedLineInputStream in = new UnbufferedLineInputStream(socket.getInputStream()); String doc = in.readLine(); logR.trace("SendDocument Got Reply [" + doc + "]"); reply = doc.getBytes(); docSent = true; }
From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java
static void export(SSTableReader reader, PrintStream outs, String[] excludes) throws IOException { Set<String> excludeSet = new HashSet<String>(); if (excludes != null) excludeSet = new HashSet<String>(Arrays.asList(excludes)); SSTableIdentityIterator row;/*from ww w. java 2s.co m*/ SSTableScanner scanner = reader.getDirectScanner(); int i = 0; // collecting keys to export while (scanner.hasNext()) { row = (SSTableIdentityIterator) scanner.next(); String currentKey = ByteBufferUtil.string(row.getKey().key); if (excludeSet.contains(currentKey)) continue; serializeRow(row, row.getKey(), outs); outs.println(); i++; } outs.flush(); scanner.close(); }