I have a large binary string \"101101110...\", and I am trying to store it into a byte array. what is the best way of doing it?
Lets say I have largeString = \"01001
You can easily build an ArrayList on which you can call toArray if you want an actual array;
List list = new ArrayList<>(); for(String str : largeString.split("(?<=\\G.{8})")) list.add(Integer.parseInt(str, 2)); System.out.println(list); // Outputs [78, 187, 96, 17, 21]