Following
snippet converts US_ASCII byte array to string.
byte[]
byteArr = {72,101,108,108,111,32,87,111,114,108,100};
String str
= new String(byteArr, StandardCharsets.US_ASCII);
package com.sample.app;
import java.nio.charset.StandardCharsets;
public class App {
public static void main(String[] args) {
byte[] byteArr = {72,101,108,108,111,32,87,111,114,108,100};
String str = new String(byteArr, StandardCharsets.US_ASCII);
System.out.println(str);
}
}
Output
Hello
World
You may
like
No comments:
Post a Comment