convert byte array to string code example

Example 1: java convert bytes to string

byte[] bytes = "hello".getBytes();
String s = new String(bytes, StandardCharsets.UTF_8);

Example 2: String by byte array in java

String str = "Example String";
 byte[] b = str.getBytes();

Example 3: convert byte array to string

byte[] byteArray1 = { 80, 65, 78, 75, 65, 74 };
String str = new String(byteArray1, 0, 3, StandardCharsets.UTF_8);

Example 4: convert array byte to string 64

byte[] temp_backToBytes = Convert.FromBase64String(temp_inBase64);

Example 5: bytearray to string python

bytesliteral   ::=  bytesprefix(shortbytes | longbytes)
bytesprefix    ::=  "b" | "B" | "br" | "Br" | "bR" | "BR"
shortbytes     ::=  "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
longbytes      ::=  "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
shortbytesitem ::=  shortbyteschar | bytesescapeseq
longbytesitem  ::=  longbyteschar | bytesescapeseq
shortbyteschar ::=  <any ASCII character except "\" or newline or the quote>
longbyteschar  ::=  <any ASCII character except "\">
bytesescapeseq ::=  "\" <any ASCII character>