diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
commit | 65bf3316cf384588453604be6b4f0ed3751a8b0f (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/java/io/Reader.java | |
parent | 8fc56618a84446beccd45b80381cdfe0e94050df (diff) | |
download | ppe42-gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.tar.gz ppe42-gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.zip |
Merged gcj-eclipse branch to trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/io/Reader.java')
-rw-r--r-- | libjava/classpath/java/io/Reader.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libjava/classpath/java/io/Reader.java b/libjava/classpath/java/io/Reader.java index 7970d9a2434..6da1813c6ca 100644 --- a/libjava/classpath/java/io/Reader.java +++ b/libjava/classpath/java/io/Reader.java @@ -1,5 +1,5 @@ /* Reader.java -- base class of classes that read input as a stream of chars - Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation + Copyright (C) 1998, 1999, 2000, 2003, 2004, 2005 Free Software Foundation This file is part of GNU Classpath. @@ -37,6 +37,8 @@ exception statement from your version. */ package java.io; +import java.nio.CharBuffer; + /* Written using "Java Class Libraries", 2nd edition, plus online * API docs for JDK 1.2 beta from http://www.javasoft.com. * Status: Believed complete and correct. @@ -53,7 +55,7 @@ package java.io; * @date April 21, 1998. * @author Aaron M. Renn (arenn@urbanophile.com) */ -public abstract class Reader +public abstract class Reader implements Closeable, Readable { /** * This is the <code>Object</code> used for synchronizing critical code @@ -152,6 +154,19 @@ public abstract class Reader return count > 0 ? buf[0] : -1; } + /** @since 1.5 */ + public int read(CharBuffer buffer) throws IOException + { + // We want to call put(), so we don't manipulate the CharBuffer + // directly. + int rem = buffer.remaining(); + char[] buf = new char[rem]; + int result = read(buf, 0, rem); + if (result != -1) + buffer.put(buf, 0, result); + return result; + } + /** * Closes the stream. Any futher attempts to read from the * stream may generate an <code>IOException</code>. |