I'm trying to divide a String into arrays. The overall program is supposed to turn binary into a string but the problem I'm having is dividing the string into arrays. I feel stupid because this seems like a simple thing to do. the binary comes like this "0100100001001001" instead of "01001000" "01001001".
public static ArrayList<String> divStr(String str,int div){
String addable = "";
ArrayList<String> ret = new ArrayList<String>();
for(int i = 0; i < str.length();i++){
addable += str.charAt(i);
if(i % div == 0 && i != 0){
ret.add(addable);
addable = "";
}
}
return ret;
}