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
This commit is contained in:
Per Bothner 1999-04-16 11:35:02 -07:00
parent a99ce7cae5
commit 839df96120
3 changed files with 120 additions and 55 deletions

View file

@ -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)