Java String(byte[] bytes, Charset charset) Constructor
Syntax
String(byte[] bytes, Charset charset) constructor from String has the following syntax.
public String(byte[] bytes, Charset charset)
Example
In the following code shows how to use String.String(byte[] bytes, Charset charset) constructor.
import java.nio.charset.Charset;
/* w w w . j av a 2 s. c o m*/
public class Main {
public static void main(String[] argv) {
byte[] bytes = new byte[]{65,66,67,68};
System.out.println(new String(bytes, Charset.forName("ASCII")));
}
}
The code above generates the following result.