English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java Program to Convert byte[] Array to String

To convert a byte [] to a String, let's first declare and initialize a byte array.

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

Now let's get a String that contains an array within it.

String str = new String(arr);

Let's see a complete example of converting a byte array to a String.

Example

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 Result

String = NO!