To interface two libraries, I need to convert an int[] array holding bytes into a byte[] array of just the low bytes. (I need to mask the ints with 0xFF and store them in a byte[] array.) I can only find examples of how to do that while converting all 4 bytes of the int, which I do not need.
As an exercise I am looking to do this with something short and efficient in pure Java 8 (i.e. valid Java 8 code without external libraries, calls, or SOUP). I tried using streams, but was unable to find a map() that worked; for example:
byte[] mybytarray = Arrays.asList(myintarray).stream().map(v -> v & 0xFF).collect(toList()).toArray(byte[]::new);
but there is the error "Cannot infer type argument(s) for map(Function)" and I do not understand how to write the map.
Arrays.streamand primitive streams.