/** * If {@link #out} implements {@link java.io.Flushable}, or is a {@link Appender} wrapper * around a flushable object, delegates to that object. Otherwise do nothing. */ @Override @SuppressWarnings("SynchronizeOnNonFinalField") public void flush() throws IOException { synchronized (lock) { IO.flush(out); } }
/** * If {@link #out} implements {@link java.io.Flushable}, or is a {@link Appender} wrapper * around a flushable object, delegates to that object. Otherwise do nothing. */ @Override @SuppressWarnings("SynchronizeOnNonFinalField") public void flush() throws IOException { synchronized (lock) { IO.flush(out); } }
/** * Sends all pending characters to the underlying appendable, including trailing whitespaces. * Note that this method should preferably be invoked at the end of a word, sentence or line, * since invoking this method may prevent {@code LineAppender} to properly wrap the current * line if the current position is in the middle of a word. * * <p>Invoking this method also flushes the underlying stream, if {@linkplain Flushable flushable}. * A cheaper way to send pending characters is to make sure that the last character is a * {@linkplain Characters#isLineOrParagraphSeparator(int) line or paragraph terminator}, * or to invoke {@link #clear()}.</p> * * @throws IOException if an I/O error occurs. */ @Override public void flush() throws IOException { out.append(buffer); buffer.setLength(0); printableLength = 0; IO.flush(out); }
/** * Sends all pending characters to the underlying appendable, including trailing whitespaces. * Note that this method should preferably be invoked at the end of a word, sentence or line, * since invoking this method may prevent {@code LineAppender} to properly wrap the current * line if the current position is in the middle of a word. * * <p>Invoking this method also flushes the underlying stream, if {@linkplain Flushable flushable}. * A cheaper way to send pending characters is to make sure that the last character is a * {@linkplain Characters#isLineOrParagraphSeparator(int) line or paragraph terminator}, * or to invoke {@link #clear()}.</p> * * @throws IOException if an I/O error occurs. */ @Override public void flush() throws IOException { out.append(buffer); buffer.setLength(0); printableLength = 0; IO.flush(out); }
/** * Flushes the table content to the underlying stream or buffer. This method should not * be called before the table is completed (otherwise, columns may have the wrong width). * * @throws IOException if an output operation failed. */ @Override public void flush() throws IOException { if (buffer.length() != 0) { nextLine(); assert buffer.length() == 0; } if (!ownOut) { writeTable(); } cells.clear(); currentRow = 0; currentColumn = 0; if (!(out instanceof TableAppender)) { /* * Flush only if this table is not included in an outer (bigger) table. * This is because flushing the outer table would break its formatting. */ IO.flush(out); } }
/** * Flushes the table content to the underlying stream or buffer. This method should not * be called before the table is completed (otherwise, columns may have the wrong width). * * @throws IOException if an output operation failed. */ @Override public void flush() throws IOException { if (buffer.length() != 0) { nextLine(); assert buffer.length() == 0; } if (!ownOut) { writeTable(); } cells.clear(); currentRow = 0; currentColumn = 0; if (!(out instanceof TableAppender)) { /* * Flush only if this table is not included in an outer (bigger) table. * This is because flushing the outer table would break its formatting. */ IO.flush(out); } }
/** * Ensures that the buffer content is equals to the given string. * * @param expected the expected content. * @throws IOException should never happen since the tests will write in a buffer. */ final void assertOutputEquals(final String expected) throws IOException { IO.flush(appender); final String actual = buffer.toString(); assertMultilinesEquals("Ignoring line separators.", expected, actual); assertEquals ("Checking line separators.", expected, actual); }