/** * @author lautturi.com * Java example: java string from byte array */ import java.nio.charset.StandardCharsets; import java.util.*; public class Lautturi { public static void main(String[] args) { byte[] bytes = {104, 101, 108, 108, 111, 32, 106, 97, 118, 97}; String str = new String(bytes, StandardCharsets.UTF_8); System.out.println(str); } }
output:
hello java