MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / toByteArray

Method toByteArray

src/main/java/org/htmlunit/util/StringUtils.java:764–770  ·  view source on GitHub ↗

Converts a string into a byte array using the specified encoding. @param charset the charset @param content the string to convert @return the String as a byte[]; if the specified encoding is not supported an empty byte[] will be returned

(final String content, final Charset charset)

Source from the content-addressed store, hash-verified

762 * @return the String as a byte[]; if the specified encoding is not supported an empty byte[] will be returned
763 */
764 public static byte[] toByteArray(final String content, final Charset charset) {
765 if (content == null || content.isEmpty()) {
766 return new byte[0];
767 }
768
769 return content.getBytes(charset);
770 }
771
772 /**
773 * Splits the provided text into an array, using whitespace as the

Callers 15

asXml_unicodeMethod · 0.95
asXmlMethod · 0.95
defaultEncodingMethod · 0.95
stringToByteArrayMethod · 0.95
getWebResponseDataMethod · 0.95
readStreamTwiceMethod · 0.45
makeWebResponseMethod · 0.45
doGetMethod · 0.45
gZippedContentMethod · 0.45

Calls 2

isEmptyMethod · 0.65
getBytesMethod · 0.65

Tested by 15

asXml_unicodeMethod · 0.76
asXmlMethod · 0.76
defaultEncodingMethod · 0.76
stringToByteArrayMethod · 0.76
readStreamTwiceMethod · 0.36
makeWebResponseMethod · 0.36
doGetMethod · 0.36
gZippedContentMethod · 0.36
binaryEncodingNoGzipMethod · 0.36