I want an InputStream to a sequence of bytes: 0, 1, 2, ... 255.
I can of course create a new byte[0x100], create a loop of int, fill it with the int values cast to byte (don't get me started on Java's signed byte type), and then form a ByteArrayInputStream from that.
But surely with Java 8 there is a better, more compact, and cleverer way. The trick seems to be generating the array of bytes. I found elsewhere that with int it's as easy as the following:
final int[] values =  IntStream.range(0, 0x100).toArray();
But I need a byte array, and there is no ByteStream. Perhaps there is an IntStream collection function that could collect the int values into a byte[] array? Or something even cleverer?
 
     
     
     
    