add write boolean to util

This commit is contained in:
dongrui 2022-05-26 13:07:08 +00:00 committed by Gitee
parent 488fbb4a63
commit 34cedb8a13
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -80,6 +80,14 @@ public class ByteUtil {
}
}
public static boolean readBoolean(ByteArrayInputStream bi) {
return bi.read() == 0x01;
}
public static void writeBoolean(ByteArrayOutputStream bo, boolean b) {
bo.write(b ? 0x01 : 0x00);
}
public static byte[] readBytes(ByteArrayInputStream bi, int len) {
byte[] ret = new byte[len];
bi.read(ret, 0, len);