Convert byte array to String in Java
Description
The following code shows how to convert byte array to String.
Example
/*from www . ja v a2 s . com*/
import java.nio.ByteBuffer;
public class Main {
public static String convertToString(byte[] array) {
String value = new String(array);
return value;
}
public static void main(String[] argv) {
System.out.println(convertToString(new byte[]{67}));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »