Convert String to Byte Array without Encoding?

So I have a string with Binary Data like this:

String lob = "ÿØÿà...";

I really have no control over this so I have to take it as it is. So I need to convert this as an InputStream without changing it, if I just do:

getBytes()

It will use the default encoding, how do I do this without any encoding or modification?

EdIT:

I can't fix this from the source. I do know the original data is a image loaded from HTML GET, but I don't know how it was encoded during transfer . All I have right now is a really long string and I need to convert it back and save it into a database.

Jon Skeet
people
quotationmark

There's no such concept as a conversion like that without encoding. You're converting between characters and bytes - those aren't the same thing, so a conversion is required, and the form of the conversion is precisely the encoding. Anything which claims to be converting without using an encoding is just assuming some specific encoding without necessarily knowing they're doing so.

If you want to get the original binary data, you need to find out what encoding was used to convert the bytes into a string to start with. You may find that ISO-8859-1 will work, but you really need to check.

At the same time, you should try very hard to change it to use something like base64. Converting arbitrary binary data to text and back like this is a recipe for disaster.

people

See more on this question at Stackoverflow