diff options
author | Per Bothner <bothner@gcc.gnu.org> | 1999-04-16 11:35:02 -0700 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 1999-04-16 11:35:02 -0700 |
commit | 839df961206ef7e5df8136e88e7edac7fa66bb54 (patch) | |
tree | d5fe22f8b6e8bfbf99f7efa65bace32141b44d8a /libjava/java/io/OutputStreamWriter.java | |
parent | a99ce7cae5a040bbf71486ab1472f61ef0ced76c (diff) | |
download | gcc-839df961206ef7e5df8136e88e7edac7fa66bb54.zip gcc-839df961206ef7e5df8136e88e7edac7fa66bb54.tar.gz gcc-839df961206ef7e5df8136e88e7edac7fa66bb54.tar.bz2 |
InputStreamReader.java (<init>): Set super.in correctly.
�
* java/io/InputStreamReader.java (<init>): Set super.in correctly.
* java/io/OutputStreamWriter.java (<init>): 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
Diffstat (limited to 'libjava/java/io/OutputStreamWriter.java')
-rw-r--r-- | libjava/java/io/OutputStreamWriter.java | 13 |
1 files changed, 9 insertions, 4 deletions
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) |