Java Question: Taking Input String - Converting to byte[] - now I need to convert byte[] back to the input string?

I have an input str, that I convert to a byte[], and now i need to convert the byte[] back to the original input string.  How is that best accomplished?
mtitaniaAsked:
Who is Participating?
 
objectsCommented:
String has a constructor for that

byte[] bytes = s.getBytes();
String s = new String(bytes);

or if a different encoding is used

String s = new String(bytes, charset)
0
 
CEHJCommented:
String s = new String(bytes)
0
 
CEHJCommented:
mtitania, can you tell me why you accepted an answer that was just a repeat of mine?

http://www.experts-exchange.com/Programming/Languages/Q_24353926.html#a24231257
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.