- Package com.yl.common.utils;
Class Byteutil {
- * Convert ISource to byte array of length Iarraylen, lower byte array is the low byte bit of integer type
Static byte[] Tobytearray (int iSource, int iarraylen) {
[] Blocalarr = new Byte[iarraylen];
(int i = 0; (I < 4) && (I < iarraylen); i++) {
) (ISource >> 8 * I & 0xFF);
Blocalarr;
- * Converts a byte array Brefarr to an integer, and the lower byte array is the low byte bit of the integer type
static int ToInt (byte[] brefarr) {
Ioutcome = 0;
Bloop;
(int i = 0; i < 4; i++) {
- Bloop = Brefarr[i];
- Ioutcome + = (Bloop & 0xFF
) << (8 * i);
Ioutcome;
Com.yl.common.utils;
Class Byteutil {
- * Convert ISource to byte array of length Iarraylen, lower byte array is the low byte bit of integer type
Static byte[] Tobytearray (int iSource, int iarraylen) {
[] Blocalarr = new Byte[iarraylen];
(int i = 0; (I < 4) && (I < iarraylen); i++) {
) (ISource >> 8 * I & 0xFF);
Blocalarr;
- * Converts a byte array Brefarr to an integer, and the lower byte array is the low byte bit of the integer type
static int ToInt (byte[] brefarr) {
Ioutcome = 0;
Bloop;
(int i = 0; i < 4; i++) {
- Bloop = Brefarr[i];
- Ioutcome + = (Bloop & 0xFF
) << (8 * i);
Ioutcome;
Original Address http://techfoxbbs.com/blog-1-5.html
byte-to-int transfer in Java