getBytes[]タイトルの通り、私と違いませserialization mechanismんString。getBytes[]以下はとの間のテストserialization mechanismです:
public void testUTF() {
byte[] data = SerializeUtil.serUTFString(str);
System.out.println(data.length);
System.out.println(str.getBytes().length);
}
ここにあるSerializeUtil:
public static byte[] serUTFString(文字列データ) {
byte[] result = null;
ObjectOutputStream oos = null;
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
try {
oos = new ObjectOutputStream(byteArray);
try {
oos.writeUTF(data);
oos.flush();
result = byteArray.toByteArray();
} finally {
oos.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
に設定strするとRedis、どちらも正しく機能しますが、getBytes[]より効率的です。byte arrayそれらはすべてfromを返すのでString、違いはserialization何ですか?