posted 17 years ago
I guess that byte array contains text in a certain character encoding, and you want to make characters out of it.
Michael's solution converts the byte values to numeric strings. So if the bytes would have the values 65, 66, 67, the string would become "656667". Is that what you want?
Vikram's solution directly casts the bytes to chars. This assumes that the bytes are perhaps ASCII characters. If the bytes would contain 65, 66, 67, you would get "ABC".
If you know what character encoding the text in the bytes is in, then you can pass that to the constructor of class String to do the conversion correctly. For example: