I am trying to get an InputStream from a String. Can somebody tell me the easy way?

In my SDK 1.4.0, I notice java.io.StringBufferInputStream. That would help but it is deprecated. The Javadoc for that class says I can get my stream from a string "via the StringReader class", but I have not seen an easy way.

Maybe they mean I am supposed to do something like this:

import java.io.*;

class StringInputStream extends InputStream{

StringReader stringReader;

  StringInputStream(String inString){
    stringReader = new StringReader(inString, "ASCII");
  }

  public int read() throws IOException{
    return stringReader.read();
  }
}

What do you think? Is that what I need to do? Or is there a more direct way in the API which I have not discovered?

Thank you,
Rich Hammer


_______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to