From d1f095551f9a602977e6fa80e91a738192c5d08c Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Thu, 6 Sep 2018 15:45:25 -0300 Subject: Fix stupid bug --- .../main/java/bjc/utils/ioutils/ReportWriter.java | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'base') diff --git a/base/src/main/java/bjc/utils/ioutils/ReportWriter.java b/base/src/main/java/bjc/utils/ioutils/ReportWriter.java index 704ec10..f083509 100644 --- a/base/src/main/java/bjc/utils/ioutils/ReportWriter.java +++ b/base/src/main/java/bjc/utils/ioutils/ReportWriter.java @@ -57,6 +57,10 @@ public class ReportWriter extends Writer { return lastChar; } + public Writer getWriter() { + return contained; + } + public boolean isLastCharNL() { return lastCharWasNL; } @@ -144,6 +148,14 @@ public class ReportWriter extends Writer { dedent(1); } + public void writeBuffer(StringBuffer sb) throws IOException { + write(sb.toString()); + + // Clear the buffer + sb.delete(0, sb.length()); + } + + @Override public void write(char[] cbuf, int off, int len) throws IOException { String actIndentStr = printTabsAsSpaces ? indentStrSpacedTabs : indentStr; @@ -164,7 +176,7 @@ public class ReportWriter extends Writer { for(int i = 0; i < len; i++) { int idx = i + off; - char c = cbuf[off]; + char c = cbuf[idx]; if(c == '\n' || c == '\r') { // Count lines written @@ -207,11 +219,23 @@ public class ReportWriter extends Writer { } } + @Override public void flush() throws IOException { contained.flush(); } + @Override public void close() throws IOException { contained.close(); } + + // @NOTE 9/5/18 + // + // There are some cases where I can imagine that you might want our + // extra info, but those are (mostly) minor, and this is more convenient + // than writing getWriter().toString() + @Override + public String toString() { + return contained.toString(); + } } -- cgit v1.2.3