Wednesday, May 04, 2005
Java IO (StringBufferInputStream and Reader)
I have a method with a signature of doStuff(InputStream input), now I want to be able to pass in an String and it seems the sensible way to do this would be using StringBufferInputStream but sadly this is deprecated. The recommended replacement is StringReader however there is no easy way to get from a Reader to an InputStream. Instead you have to bodge it with something like new ByteArrayInputStream(string.getBytes()); Sadly it seems that this bug has been around far too long and Sun still havn't fixed it.