HI,
Can any one know how to convert byte array into char array.

For example :

byte buf[]=teststr.getBytes();

Note:
buf is byte array. I need to convert this into char array.

Edited 6 Years Ago by __avd: Remove [code] tags.

Why use getBytes? Why don't you use toCharArray? In any case, the easiest way (although not necessarily the most effecient) is to do new String(byte[]).toCharArray() .

Edited 6 Years Ago by masijade: n/a

HI,
I am retriveing Vector values using getBytes.

// Her teststr is Vector..... Using toCharArray() i cant retrive these values...... So any other option is there......
For example :

byte buf[]=teststr.getBytes();

Note:
buf is byte array. I need to convert this into char array.

What? What are you talking about? If you need these "bytes" as "chars" then do new String -> toCharArray There is no reason you cannot do that, unless those "bytes" do not represent characters (i.e. a String) and so "converting" them to chars would be pointless anyway.

I still have no idea what you mean by "Her teststr is Vector". Are you saying that this "byte buffer" is a serialised Vector object maybe? In which case this "conversion" is less than pointless anyway.

Hi,
I got the output for my project .... .... masijade thanks for your information friend......

This question has already been answered. Start a new discussion instead.