How to convert byte array to string in javaferer to:lautturi.com/**
* @author lautturi.com
* Java example: converting byte array to string in java
*/
import java.util.*;
import java.io.UnsupportedEncodingException;
public class Lautturi {
public static void main(String[] args) {
byte[] bytes = {108, 97, 117, 116, 116, 117, 114, 105, 32, 106, 97, 118, 97, 33};
String str;
try {
str = new String(bytes,"utf-8");
System.out.println(str);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}