更新时间:2021-06-27 07:15:55
简短的回答是否。有没有简单的方法来重新导入从String对象,因为某些类型的信息在失去的toString()
序列化。
The short answer is "No". There is no simple way to re-import an Object from a String, since certain type information is lost in the toString()
serialization.
不过,对于特定的格式和特定(已知)类型的,你应该能够编写code解析手动的字符串:
However, for specific formats, and specific (known) types, you should be able to write code to parse a String manually:
// Takes Strings like "[a, b, c]"
public List parse(String s) {
List output = new ArrayList();
String listString = s.substring(0, s.length - 1); // chop off brackets
for (String token : new StringTokenizer(listString, ",")) {
output.add(token.trim);
}
return output;
}
从他们的连载表格对象的重构通常被称为反序列化
Reconstituting objects from their serialized form is generally called deserialization