Dave's Brain

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);

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.