Arguments in many methods in the Java APIs are of the type InputStream. This is how to get an InputStream from a String, where argument to getBytes, UTF-8, is the encoding to use:
InputStream is = new ByteArrayInputStream(myString.getBytes("UTF-8"));
[tags]Java[/tags]
Thanks for the code, it helped me a lot.
Thanks for the code. It is very useful.
I’ve been looking for this code for hours.
Thanks for post it.
Thankx a lot..,
This code is very simple and works excellent.
Once again, Thankx a lot buddy.!
Helped me too !!
thanks, it helps me so much
Code is correct except for the particular overload of GetBytes. You should _always_ specify an encoding when calling GetBytes, e.g. myString.GetBytes(‘UTF-8’). The bare form of GetBytes shouldn’t be used.
@Steve, I am embarrassed to see that I missed that in the code. Thanks for the heads up!
Thanks, really helped with a xml file!
Thank you… helped a lot
Thanks so much…I like something simple..:)
This helped me too.
Thanks Johan!
Thanks a lot.
simple and precise
Code is awsome. It save me many hours.