创建字节流

时间:2018-01-03 01:12:25

标签: java arrays java-stream

在Java 8中,我发现这有点奇怪。我似乎无法从byte[]数组中创建字节流。 Array.stream课程似乎仅适用于int[]long[]double[]T[]

public long update(final byte[] buffer) {
    crc = 0L;
    Arrays.stream(buffer).forEach(this::update); // expecting to go into a function update(byte b)
    return crc;
}

当我尝试Stream.of(buffer)Arrays.asList(buffer).stream().forEach(this::update);之类的替代方案时,流只是反映了自己,我得到了byte[]

我在这里的实现中遗漏了什么?

0 个答案:

没有答案