• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

byte[] to String

 
Peter Kovgan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there simple way to convert byte array to String?
There is the way I know:

[ November 19, 2003: Message edited by: Peter Kovgan ]
 
Seid Myadiyev
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Peter,
This is from J2SE API doc:
"String(byte[] bytes)
Constructs a new String by decoding the specified array of bytes using the platform's default charset."
byte[] byteArray = ...
String name = new String(byteArray);
Thanks,
+Seid
 
Peter Kovgan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Seid!
so easy!
 
Stephen Galbraith
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... in addition, by calling

you can decode the string into various forms
see:
http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html
 
Peter Kovgan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, Stephen, thank you, very helpful!
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyone out there working on this type of byte conversion that could help with the update problem listed in this thread ?
Thanks.
TJ
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic