在研發期間,將開發過程比較常用的內容記錄起來,下面內容段是關於Java轉換整形(int)為字節數組(byte array)的內容,希望能對碼農們有所幫助。
public static byte[] intToByteArray(int value) {
byte[] b = new byte[4];
for (int i = 0; i < 4; i++) {
b[i] = (byte) ((value >>> offset) & 0xFF);
}
return b;
}
在研發期間,將開發過程比較常用的內容記錄起來,下面內容段是關於Java轉換整形(int)為字節數組(byte array)的內容,希望能對碼農們有所幫助。
public static byte[] intToByteArray(int value) {
byte[] b = new byte[4];
for (int i = 0; i < 4; i++) {
b[i] = (byte) ((value >>> offset) & 0xFF);
}
return b;
}
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。