Replacement for StringBufferInputStream

From EggeWiki

Jump to: navigation, search

Bug ID: 4217782 States that StringBufferInputStream is depreciated and should be replaced with StringReader, but StringReader is not an input stream. I frequently need to turn a String into a stream for testing, so I created this class:

class StringReaderInputStream extends InputStream {
 
    private final StringReader reader;
 
    public StringReaderInputStream(String s) {
        reader = new StringReader(s);
    }
 
    public int read() throws IOException {
        return reader.read();
    }
}
Personal tools
Travelling Salesman

Get the app!