/** * Return the body content as a string. * @param charset the charset to use to turn the body content to a String */ public String getBodyAsString(Charset charset) { byte[] bytes = getBodyAsBytes(); return new String(bytes, charset); }
/** * Return the body content as a string. * @param charset the charset to use to turn the body content to a String */ public String getBodyAsString(Charset charset) { byte[] bytes = getBodyAsBytes(); return new String(bytes, charset); }
/** * Return the body content as a string. * @param charset the charset to use to turn the body content to a String */ public String getBodyAsString(Charset charset) { byte[] bytes = getBodyAsBytes(); try { return new String(bytes, charset.name()); } catch (UnsupportedEncodingException ex) { // should not occur throw new IllegalStateException(ex); } }
/** * Return the body content as a string. * @param charset the charset to use to turn the body content to a String */ public String getBodyAsString(Charset charset) { byte[] bytes = getBodyAsBytes(); try { // Use return new String(bytes, charset.name()); } catch (UnsupportedEncodingException ex) { // should not occur throw new InternalError(ex.getMessage()); } }