for(int i=0;i<encryptedData.length;i++){
System.out.print(encryptedData[i]);
}
for(int i=0;i<new String(encryptedData).getBytes().length;i++){
System.out.print(new String(encryptedData).getBytes()[i]);
}打印结果为:-60-1242379-35-41-669857-3226821206481-76
-60-1242379-35-41-669857632682120648163为什么不一致,怎样才能一致呢
System.out.print(encryptedData[i]);
}
for(int i=0;i<new String(encryptedData).getBytes().length;i++){
System.out.print(new String(encryptedData).getBytes()[i]);
}打印结果为:-60-1242379-35-41-669857-3226821206481-76
-60-1242379-35-41-669857632682120648163为什么不一致,怎样才能一致呢
STRING. byte[] getBytes 形成BYTE STRING STR=NEW STRING(BYTE[],"UTF")再返回去,不是用输出的
String(byte[] bytes)
构造一个新的 String,方法是使用平台的默认字符集解码字节的指定数组。
并不是每个byte[]都能正好转成字符串
一下是按照lixiaolue85所说的改过的(PS:是这样改么),可问题依旧: for(int i=0;i<encryptedData.length;i++){
System.out.print(encryptedData[i]);
}
String str= new String(encryptedData,"UTF-8");for(int i=0;i<str.getBytes("UTF-8").length;i++){ System.out.print(str.getBytes("UTF-8")[i]); }谁能解决?