Here you can find the source of getContentAsString(byte[] content, Charset charset)
Parameter | Description |
---|---|
content | bytes to convert to a String |
charset | the character set of the content |
Parameter | Description |
---|---|
IllegalArgumentException | if charset is null |
public static String getContentAsString(byte[] content, Charset charset)
//package com.java2s; //License from project: Apache License import java.nio.charset.Charset; public class Main { /**//w w w .j av a 2 s . c o m * Converts the byte array into a String based on the specified charset. The charset cannot be null. * * @param content bytes to convert to a String * @param charset the character set of the content * @return String containing the converted content * @throws IllegalArgumentException if charset is null */ public static String getContentAsString(byte[] content, Charset charset) { if (charset == null) { throw new IllegalArgumentException("Charset cannot be null"); } return new String(content, charset); } }