Replacement for StringBufferInputStream

From EggeWiki
Revision as of 22:38, 8 October 2009 by Brianegge (talk | contribs) (Created page with '[http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4217782 Bug ID: 4217782] States that StringBufferInputStream is depreciated and should be replaced with StringReader, but Stri…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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>