corda/classpath/java/io/StringReader.java
2007-08-14 07:27:10 -06:00

25 lines
531 B
Java

package java.io;
public class StringReader extends Reader {
private final String in;
private int position = 0;
public StringReader(String in) {
this.in = in;
}
public int read(char[] b, int offset, int length) throws IOException {
if (length > in.length() - position) {
length = in.length() - position;
if (length <= 0) {
return -1;
}
}
in.getChars(position, length, b, offset);
position += length;
return length;
}
public void close() throws IOException { }
}