medhaj hambi wrote:Is there a way I can use java.nio package for byte to char array conversion ? Due to some technical reason, I have to write a code and have to use the package java.nio and I am not able to figure out a way to do that. It will be great if someone can suggest me or provide me a sample code snippet. Really appreciate your help !
OK, well you can create a
ByteBuffer with
ByteBuffer.wrap(byte[]). After that, follow Campbell's advice.
If we simply hand you the code, you won't learn because you really need to try these things out
for yourself.
It's also worth mentioning that
byte→char conversion is rarely as simple as it sounds. If it's bog-standard 7-bit ASCII
you should be fine, but there are any number of "codepages" out there (like Windows-1252), which may require specific mapping, so it's important to understand ALL the requirements before you start.
HIH
Winston