Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
String item="stringItem";
需要将此字符串项转换为字节数组
byte[] byteItemArray = stringItem.getByte();
这会引发类转换异常。我应该使用类型转换吗?
尝试byte [] val= ((String) getValue(key)).getBytes();
byte [] val= ((String) getValue(key)).getBytes();
由此我怀疑这条线导致了类转换异常
(byte[]) getValue(key);
getValue() 返回什么。如果它没有返回 byte[] 的对象,您将得到异常。
尝试这个:
(byte[]) getValue(key).getBytes();