diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
commit | 97b8365cafc3a344a22d3980b8ed885f5c6d8357 (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/java/io/Reader.java | |
parent | c648dedbde727ca3f883bb5fd773aa4af70d3369 (diff) | |
download | gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.zip gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.gz gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.bz2 |
Merged gcj-eclipse branch to trunk.
From-SVN: r120621
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 7970d9a..6da1813 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>. |