如何将字符串转换为位然后转换为int数组 - java

Yod*_*oda 5 java string int bits bit

如何在Java中将字符串转换为位(不是字节)或位数组(我稍后会做一些操作)以及如何转换为整数数组(每32位转换成int然后将它放入数组中?我有从未在Java中进行过这种转换.

String->array of bits->(some operations I'll handle them)->array of ints
Run Code Online (Sandbox Code Playgroud)

Lou*_*man 9

ByteBuffer bytes = ByteBuffer.wrap(string.getBytes(charset));
  // you must specify a charset
IntBuffer ints = bytes.asIntBuffer();
int numInts = ints.remaining();
int[] result = new int[numInts];
ints.get(result);
Run Code Online (Sandbox Code Playgroud)