From 839df961206ef7e5df8136e88e7edac7fa66bb54 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Fri, 16 Apr 1999 11:35:02 -0700 Subject: InputStreamReader.java (): Set super.in correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit � * java/io/InputStreamReader.java (): Set super.in correctly. * java/io/OutputStreamWriter.java (): Set super.in correctly. (writeChars): Don't be quite so eager to flush. * java/io/PrintStream.java: Rewrite. Now more similar to OutputStreamWriter, using explicit UnicodeToBytes converter. Also, autoflush does not need to flush so often. * java/lang/natString.cc (getBytes): More efficient algorithm. (init(jbyteArray,jint,jint,jstring)): More efficient. From-SVN: r26509 --- libjava/java/io/OutputStreamWriter.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libjava/java/io/OutputStreamWriter.java') diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java index e529474..88841d9 100644 --- a/libjava/java/io/OutputStreamWriter.java +++ b/libjava/java/io/OutputStreamWriter.java @@ -32,9 +32,9 @@ public class OutputStreamWriter extends Writer private OutputStreamWriter(OutputStream out, UnicodeToBytes encoder) { - super(out); - this.out = out instanceof BufferedOutputStream ? (BufferedOutputStream) out - : new BufferedOutputStream(out, 2048); + super((this.out = (out instanceof BufferedOutputStream + ? (BufferedOutputStream) out + : new BufferedOutputStream(out, 250)))); this.converter = encoder; } @@ -90,12 +90,17 @@ public class OutputStreamWriter extends Writer } } + /** Writes characters through to the inferior BufferedOutputStream. + * Ignores wcount and the work buffer. */ private void writeChars(char[] buf, int offset, int count) throws IOException { while (count > 0) { - if (out.count != 0) + // We must flush if out.count == out.buf.length. + // It is probably a good idea to flush if out.buf is almost full. + // This test is an approximation for "almost full". + if (out.count + count >= out.buf.length) { out.flush(); if (out.count != 0) -- cgit v1.1