java.io
Class StringReader
- Closeable, Readable
This class permits a
String
to be read as a character
input stream.
The mark/reset functionality in this class behaves differently than
normal. If no mark has been set, then calling the
reset()
method rewinds the read pointer to the beginning of the
String
.
StringReader(String buffer) - Create a new
StringReader that will read chars from the
passed in String .
|
void | close() - Closes the stream represented by this class, thus freeing
system resources.
|
void | mark(int readAheadLimit)
|
boolean | markSupported()
|
int | read()
|
int | read(char[] b, int off, int len)
|
boolean | ready() - This method determines if the stream is ready to be read.
|
void | reset() - Sets the read position in the stream to the previously
marked position or to 0 (i.e., the beginning of the stream) if the mark
has not already been set.
|
long | skip(long n) - This method attempts to skip the requested number of chars in the
input stream.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
StringReader
public StringReader(String buffer)
Create a new StringReader
that will read chars from the
passed in String
. This stream will read from the beginning
to the end of the String
.
buffer
- The String
this stream will read from.
close
public void close()
Closes the stream represented by this class, thus freeing
system resources. In that case that the stream is already
in the closed state, this method has no effect.
- close in interface Closeable
- close in interface Reader
ready
public boolean ready()
throws IOException
This method determines if the stream is ready to be read. This class
is always ready to read and so always returns true
, unless
close() has previously been called in which case an IOException is
thrown.
- ready in interface Reader
true
to indicate that this object is ready to be read.
reset
public void reset()
throws IOException
Sets the read position in the stream to the previously
marked position or to 0 (i.e., the beginning of the stream) if the mark
has not already been set.
- reset in interface Reader
skip
public long skip(long n)
throws IOException
This method attempts to skip the requested number of chars in the
input stream. It does this by advancing the pos
value by
the specified number of chars. It this would exceed the length of the
buffer, then only enough chars are skipped to position the stream at
the end of the buffer. The actual number of chars skipped is returned.
- skip in interface Reader
n
- The requested number of chars to skip
- The actual number of chars skipped.
StringReader.java -- permits a String to be read as a character input stream
Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.