MCPcopy Create free account
hub / github.com/curtcox/JLHTTP / getBytes

Method getBytes

src/main/java/net/freeutils/httpserver/HTTPServer.java:2683–2693  ·  view source on GitHub ↗

Converts strings to bytes by casting the chars to bytes. This is a fast way to encode a string as ISO-8859-1/US-ASCII bytes. If multiple strings are provided, their bytes are concatenated. @param strings the strings to convert (containing only ISO-8859-1 chars) @return the byte array

(String... strings)

Source from the content-addressed store, hash-verified

2681 * @return the byte array
2682 */
2683 public static byte[] getBytes(String... strings) {
2684 int n = 0;
2685 for (String s : strings)
2686 n += s.length();
2687 byte[] b = new byte[n];
2688 n = 0;
2689 for (String s : strings)
2690 for (int i = 0, len = s.length(); i < len; i++)
2691 b[n++] = (byte)s.charAt(i);
2692 return b;
2693 }
2694
2695 /**
2696 * Transfers data from an input stream to an output stream.

Callers 6

handleTraceMethod · 0.95
initChunkMethod · 0.80
MultipartIteratorMethod · 0.80
writeToMethod · 0.80
sendHeadersMethod · 0.80
sendMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected