将整个字节数组左移一位的最佳方法是什么?我从固定长度为 32 的字节数组开始,也想获得 32 长字节数组,但向左移动了一位。 示例:
Input array -> 01000001 00100000 01010100 01100101
Output array -> 10000010 01000000 10101000 11001010
如果有好的功能,我可以使用 Guava。
最佳答案
尝试使用 BigInteger
,像这样:
byte[] outputArray = new BigInteger(1, inputArray).shiftLeft().toByteArray();
关于java - 左移包装整个字节数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44717795/