Convert Byte Array to String in Java



To convert byte[] to String, firstly let us declare and initialize a byte array.

// byte array byte[] arr = new byte[] {78, 79, 33};

Now take a String and include the array in it.

String str = new String(arr);

Let us see the complete example to convert byte array to String.

Example

 Live Demo

public class Demo {    public static void main(String args[]) {       // byte array       byte[] arr = new byte[] {78, 79, 33};       String str = new String(arr);       // string       System.out.println("String = "+str);    } }

Output

String = NO!
Updated on: 2020-06-26T10:25:04+05:30

941 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements
close