Skip to content

Commit

Permalink
Avoid buffering when using WriterOutputStream
Browse files Browse the repository at this point in the history
Call flush() whenever bytes are written to the OutputStream.
  • Loading branch information
stephan-gh committed Sep 18, 2017
1 parent 4344091 commit 2012f13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public AbstractWindowsTerminal(Writer writer, String name, int codepage, boolean
this.writer = new PrintWriter(writer);
// Grab the console code page and find a matching charset to encode
Charset charset = getConsoleEncoding(codepage);
this.output = new BufferedOutputStream(new WriterOutputStream(writer, charset));
this.output = new WriterOutputStream(writer, charset);
parseInfoCmp();
// Attributes
attributes.setLocalFlag(Attributes.LocalFlag.ISIG, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ public WriterOutputStream(Writer out, Charset charset) {
@Override
public void write(int b) throws IOException {
out.write(b);
flush();
}

@Override
public void write(byte[] b) throws IOException {
out.write(new String(b, this.charset));
flush();
}

@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(new String(b, off, len, this.charset));
flush();
}

@Override
Expand Down

0 comments on commit 2012f13

Please sign in to comment.