English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Pour convertir un byte [] en chaîne, déclarons et initialisons d'abord un tableau de bytes.
//Tableau de bytes byte[] arr = new byte[] {78, 79, 33};
Maintenant, obtenons une chaîne qui contient l'array.
String str = new Chaîne(arr);
Voyons un exemple complet de conversion d'un tableau de bytes en chaîne de caractères.
public class Demo { public static void main(String args[]) { //Tableau de bytes byte[] arr = new byte[] {78, 79, 33}; Chaîne str = new Chaîne(arr); //Chaîne System.out.println("String = ",+str); } }
Résultat de la sortie
String = NON!