String(byte[] bytes, Charset charset) constructor from String has the following syntax.
public String(byte[] bytes, Charset charset)
In the following code shows how to use String.String(byte[] bytes, Charset charset) constructor.
import java.nio.charset.Charset; //from w w w .ja v a 2s . 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.