Hello,
I'm working on a project these days, where I'm not responsible for the framework I have to work within. Now, ther are some problems with the encoding and special characters:
I've got to process text from an InputStream, and return an InputStream itself again. For this processing, I need the complete
String from the given InputStream. Furthermore, I have to assume that the text in the InputStream contains every sort of characters, special characters and such. I assume, that the content of the InputStream is UTF-8 encoded.
Now, my first question is: Is this even possible? As far as I read, InputStreams work with bytes and byteArrays. byte can only take the values from -128 to 127, no? So, how can UTF-8 text be stored in an InputStream?
Now, assuming the answer to the question above is "yes" - I read the text from the Stream with an InputStreamReader, and I'm processing some form of output, as String.
How can I create an InputStream that contains the output, and ensure UTF-8 compatibility? Until now, I just found a possibility with ByteArrayInputStream, but they say it's deprecated, and I have to use a StringReader. But how can I convert/transform a StringReader into an InputStream?
-- PS: 1) Sorry for this post in the first place -- I had a total blackout and postet it in my mother language ^^
2) ByteArrayInputstream seems to work - but they say, that there is a more preferable way with StringReader. Mh.
Thanks in Advance!
Simon