byte[] bytes=new byte[] {
-58,-85,55,7};
Arrays.toString(bytes)
/**
* 解码byte[]数组的字符串变成byte[]
* @param byteAKeyString 数据库byte[]数组的字符串
* @return 转换后的byte[] 字符串
*/
private byte[] stringToBytes(String byteAKeyString){
String trim = StringUtils.strip(byteAKeyString,"[]") //去掉两边括号
.replaceAll("\\s*","");//去掉空格
String[] split = trim.split (",");
int[] ids = Arrays.asList(split).stream().mapToInt(Integer::parseInt).toArray(); //利用Lambda表达式进行类型转换,转成int数组
byte[] bytes = new byte[ids.length];
for (int i = 0; i < ids.length; i++) {
bytes[i]= (byte) ids[i];
}
return bytes;
}
java的byte[]数组转成字符串并且再转回byte[]数组
猜你喜欢
转载自blog.csdn.net/qq_45844443/article/details/127096364
今日推荐
周排行