@Override public void close() throws IOException { flush(); // Log whatever remaining. There shouldn't be line separator anymore after the flush() call. log(buffer.toString(StandardCharsets.UTF_8)); }
@Override public void close() throws IOException { flush(); // Log whatever remaining. There shouldn't be line separator anymore after the flush() call. log(buffer.toString(StandardCharsets.UTF_8)); }
@Override public void flush() throws IOException { if (outStream != null) { outStream.flush(); } out.flush(); // Write out buffered data, line by line. // The last line may not be written out if it doesn't have a line separator. int len = buffer.bytesBefore((byte) '\n'); while (len >= 0) { if (len == 0) { log(""); } else { CharSequence line = buffer.readCharSequence(len, StandardCharsets.UTF_8); if (line.charAt(line.length() - 1) == '\r') { line = line.subSequence(0, line.length() - 1); } log(line.toString()); } // Read the '\n' buffer.readByte(); len = buffer.bytesBefore((byte) '\n'); } if (!buffer.isReadable()) { buffer.clear(); } else { buffer.discardReadBytes(); } }
@Override public void flush() throws IOException { if (outStream != null) { outStream.flush(); } out.flush(); // Write out buffered data, line by line. // The last line may not be written out if it doesn't have a line separator. int len = buffer.bytesBefore((byte) '\n'); while (len >= 0) { if (len == 0) { log(""); } else { CharSequence line = buffer.readCharSequence(len, StandardCharsets.UTF_8); if (line.charAt(line.length() - 1) == '\r') { line = line.subSequence(0, line.length() - 1); } log(line.toString()); } // Read the '\n' buffer.readByte(); len = buffer.bytesBefore((byte) '\n'); } if (!buffer.isReadable()) { buffer.clear(); } else { buffer.discardReadBytes(); } }