java - How to convert String containing binary representation into int array -
after many calculations have string containing binary representation of data. how convert array of ints in consistent way.
i can take every 32 bits , put array doesn't seem solution.
parsing each 32 bit section seems solution me. note it's best use long parsing, avoid problems if leading digit 1. example:
public static int[] parsebinarytointarray(string input) { // todo: validation int[] output = new int[input.length() / 32]; (int = 0; < output.length; i++) { string section = input.substring(i * 32, (i + 1) * 32); output[i] = (int) long.parselong(section, 2); } return output; }  
Comments
Post a Comment