[問題] 請問一下為何要做bitwise運算

看板java作者 (吃哈吱)時間13年前 (2011/03/28 14:56), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
最近在研究android nfc的功能. 有一段是在parse出nfcrecord的payload. 請問這部份使用bitwise用意為何呢? 謝謝. static NDEFRecord readRecord(byte[] bytes, int offset) { int header = bytes[offset] & 0xFF; // Does header match what we support in the bits we care about? // XOR figures out where we differ, and if any of those are in the mask, fail if (((header ^ SUPPORTED_HEADER) & SUPPORTED_HEADER_MASK) != 0) { return null; } int typeLength = bytes[offset + 1] & 0xFF; int payloadLength = bytes[offset + 2] & 0xFF; String type = AbstractNDEFParsedResult.bytesToString(bytes, offset + 3, typeLength, "US-ASCII"); byte[] payload = new byte[payloadLength]; System.arraycopy(bytes, offset + 3 + typeLength, payload, 0, payloadLength); return new NDEFRecord(header, type, payload, 3 + typeLength + payloadLength); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.110.117.10
文章代碼(AID): #1Da344FJ (java)
文章代碼(AID): #1Da344FJ (java)