aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/io/OutputStreamWriter.java
diff options
context:
space:
mode:
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 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)