Returns a string containing the supplied byte values separated by separator. For example, join(":", (byte) 1, (byte) 2, (byte) 255) returns the string "1:2:255". @param separator the text that should appear between consecutive values in the resulting string (but
(String separator, byte... array)
| 260 | |
| 261 | |
| 262 | public static String join(String separator, byte... array) { |
| 263 | checkNotNull(separator); |
| 264 | if (array.length == 0) { |
| 265 | return ""; |
| 266 | } |
| 267 | |
| 268 | // For pre-sizing a builder, just get the right order of magnitude |
| 269 | StringBuilder builder = new StringBuilder(array.length * (3 + separator.length())); |
| 270 | builder.append(toInt(array[0])); |
| 271 | for (int i = 1; i < array.length; i++) { |
| 272 | builder.append(separator).append(toString(array[i])); |
| 273 | } |
| 274 | return builder.toString(); |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Returns a comparator that compares two {@code byte} arrays <a |