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.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java
index e4ecbdb..8a47fdf 100644
--- a/libjava/java/io/OutputStreamWriter.java
+++ b/libjava/java/io/OutputStreamWriter.java
@@ -215,7 +215,7 @@ public class OutputStreamWriter extends Writer
private void writeChars(char[] buf, int offset, int count)
throws IOException
{
- while (count > 0)
+ while (count > 0 || converter.havePendingBytes())
{
// We must flush if out.count == out.buf.length.
// It is probably a good idea to flush if out.buf is almost full.
@@ -228,6 +228,13 @@ public class OutputStreamWriter extends Writer
}
converter.setOutput(out.buf, out.count);
int converted = converter.write(buf, offset, count);
+ // Flush if we cannot make progress.
+ if (converted == 0 && out.count == converter.count)
+ {
+ out.flush();
+ if (out.count != 0)
+ throw new IOException("unable to flush output byte buffer");
+ }
offset += converted;
count -= converted;
out.count = converter.count;