本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
二進位資料處理變更
在第 1 版中,二進位資料是直接使用 ByteBuffer
物件處理。在第 2 版中,軟體開發套件使用SdkBytes
物件,提供更便利且類型安全的方式來使用二進位資料。
您可以使用遷移工具ByteBuffer
自動SdkBytes
轉換為 ,也可以在傳回的SdkBytes
物件asByteBuffer()
上呼叫 ,手動將其轉換為 。
範例 - 從第 1 版中的訊息屬性取得二進位資料
// Get binary data from a message attribute MessageAttributeValue messageAttributeValue = new MessageAttributeValue(); ByteBuffer binaryValue = messageAttributeValue.getBinaryValue(); String binaryString = new String(messageAttributeValue.getBinaryValue().array());
範例 - 從第 2 版中的訊息屬性取得二進位資料
// Get binary data from a message attribute MessageAttributeValue messageAttributeValue = MessageAttributeValue.builder().build(); ByteBuffer binaryValue = messageAttributeValue.binaryValue().asByteBuffer(); String binaryString = new String(messageAttributeValue.binaryValue().asByteBuffer().array());