summaryrefslogtreecommitdiff
path: root/libjava/java/io/OutputStreamWriter.java
diff options
context:
space:
mode:
authorbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>1999-04-16 18:35:02 +0000
committerbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>1999-04-16 18:35:02 +0000
commit7a99bc49d7951d74a4dbee4793a0884bac116a1d (patch)
treed5fe22f8b6e8bfbf99f7efa65bace32141b44d8a /libjava/java/io/OutputStreamWriter.java
parenteab819ff4c13c432f46313dd15872aa6cfd95638 (diff)
downloadgcc-7a99bc49d7951d74a4dbee4793a0884bac116a1d.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26509 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/io/OutputStreamWriter.java')
-rw-r--r--libjava/java/io/OutputStreamWriter.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java
index e529474875c..88841d9c1b4 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)