0

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 by __avd: Remove [code] tags.

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by kgkamaraj
Featured Replies
  • 1

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

1

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 by masijade: n/a

0

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.

0

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.

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.