Jump to content

Replacement for StringBufferInputStream

From EggeWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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:

<geshi lang="java5"> class StringReaderInputStream extends InputStream {

   private final StringReader reader;
   public StringReaderInputStream(String s) {
       reader = new StringReader(s);
   }
   public int read() throws IOException {
       return reader.read();
   }

} </geshi>