Browse - Programming Tips - How do I convert a byte array to/from a String?

Date: 2012feb10
Language: Java
Level: beginner

Q.  How do I convert a byte array to/from a String?

A.

Converting a String to a byte array:

byte[] mybytes = mystring.getBytes()
Converting a byte array to a String:
String mystring = new String(mybytes);