Java
/**
* 00 11 22 33 44 55 66 77
*/
@NonNull
public String expression(byte[] bytes) {
final StringBuilder sb = new StringBuilder();
boolean firstTime = true;
for (byte each : bytes) {
if (firstTime) {
firstTime = false;
} else {
sb.append(" ");
}
sb.append(hex(each));
}
return sb.toString();
}
Java その2
/**
* 00 11 22 33 44 55 66 77
*/
@NonNull
public String expression(byte[] bytes) {
final List<String> tokens = new ArrayList<>();
for (byte each : bytes) {
tokens.add(hex(each));
}
return TextUtils.join(" ", tokens);
}
Kotlin
/**
* 00 11 22 33 44 55 66 77
*/
fun expression(bytes : ByteArray): String {
return bytes.joinToString(separator = " ", transform = { hex(it) })
}
0 件のコメント:
コメントを投稿