-3
A
回答
0
試試這個:
List<Byte> array = new ArrayList<Byte>();
array.add((byte)1);
array.add((byte)3);
//etc..
Byte[] arrayBytes = array.toArray(new Byte[array.size()]);
byte[] byteArray = Bytes.toArray(array);
0
實施
import java.util.ArrayList;
import java.util.List;
public class ByteArrayList {
private List<Byte> bytesList;
public ByteArrayList() {
bytesList = new ArrayList<Byte>();
}
public void add(byte[] bytes) {
add(bytes, 0, bytes.length);
}
public void add(byte[] bytes, int offset, int length) {
for (int i = offset; i < (offset + length); i++) {
bytesList.add(bytes[i]);
}
}
public byte[] getArray() {
byte[] bytes = new byte[bytesList.size()];
for (int i = 0; i < bytesList.size(); i++) {
bytes[i] = bytesList.get(i);
}
return bytes;
}
}
相關問題
- 1. 如何存儲在字符串數組數組列表值
- 2. 如何存儲多個字節數組
- 3. 如何比較字節數組和字節數組列表?
- 4. C#在字節數組中存儲int
- 5. 存儲在數組列表
- 6. Java如何將音頻數據存儲在字節數組中。
- 7. 如何在android中存儲帳戶數組列表?
- 8. 將多組數字存儲到字節數組中
- 9. 如何在列族中存儲數組
- 10. 如何將數組列表項存儲在字符串中
- 11. 如何在字符類型數組中存儲列表
- 12. 從Java中存儲MySQL字節數組
- 13. 如何在字典中存儲數組
- 14. 節點:如何存儲JSON數組在谷歌數據存儲
- 15. 如何遍歷字節數組列表...?
- 16. 轉換字節數組的字節位和存儲在整數數組
- 17. 數組列表存儲到在c#另一個數組列表
- 18. 如何在C中存儲字節數組?
- 19. 如何在Oracle中存儲字節數組?
- 20. 如何在Postgres中查詢數組存儲列(數組相交)
- 21. 將8字節值的每個字節存儲在數組中
- 22. Java-如何將數據臨時存儲在數組列表中
- 23. sqllite數據庫字段如何存儲數組列表
- 24. 在數組中存儲XML節點
- 25. 存儲一個字節數組
- 26. C#:將字節數組存儲爲XML
- 27. 我如何在android數據庫中存儲android json數組?
- 28. 在Android中的Bundle中存儲和檢索數組列表
- 29. 如何在16字節數組中存儲32位十六進制數字?
- 30. 在Android上的8位字節數組上存儲16Bit音頻
編輯的問題與到目前爲止的代碼,如果你是不是在找downvotes! – OBX
@oblivion我需要的答案,而不是投票。卡住!!.. –