【发布时间】:2018-08-03 23:32:15
【问题描述】:
我正在尝试对带有流的字节数组进行按位运算,但它给我的错误是“不可转换的类型;不能将 'byte[]' 转换为 'int'”。我想通过流对字节数组中的每个项目按位使用 0xff。
byte[] packet;
//this does not work
Stream.of(packet).parallel().map(e->(int)e&0xff)//then put int into an array or list
//basically this is what I am trying to do with streams
int[] castedValues = new int[packet.length];
for (int i = 0; i < packet.length; i++) {
castedValues[i] = packet[i];
}
【问题讨论】:
标签: java arrays java-stream bitwise-and