Convert Byte[] array to String in Java

Let’s see how we can convert a byte array to a string using Java.

Code

String ex = "example";
byte[] b = ex.getBytes();
 
ex = new String(b);
System.out.println(ex);

String ex = b.toString(); is NOT working correctly!

Categories: Java Tags: , , , ,
%d bloggers like this: