java - No method to get stream of byte array -


i want stream of byte array came know arrays not have method stream of byte array.

byte[] bytearr = new byte[100]; arrays.stream(bytearr);//compile time error 

my questions,

  • why feature not supported ?
  • how can stream of byte array ?

note : know can use byte[] instead of byte[] not answer question.

there 3 types of primitive streams: intstream, longstream , doublestream.

so, closest can have intstream, each byte in array promoted int.

afaik, simplest way build 1 byte array is

    intstream.builder builder = intstream.builder();     (byte b : bytearray) {         builder.accept(b);     }     intstream stream = builder.build(); 

edit: assylias suggests another, shorter way:

intstream stream = intstream.range(0, bytearr.length)                             .map(i -> bytearray[i]); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -