我有一个带有字段和新值的base64字符串,现在需要通过在特定字段添加值并序列化回base64字符串来完成转换。
String base64ip = BXNyKCRNb25leX3DsipxKQIBSQV2YWx1ZXhw
fieldname = value
value = 20
Output base64op = BXNyKCRNb25leX3DsipxKQIBSQV2YWx1ZXhw with some modification in between due to value.
我想为特定的字段名添加值20,并以序列化的base64格式返回输出,该怎么做? 我尝试使用可序列化类的writeobject方法,但没有帮助。
Modify p = new Modify(fieldName, newValue);
FileOutputStream fos = null;
ObjectOutputStream out = null;
try {
fos = new FileOutputStream(base64ip);
out = new ObjectOutputStream(fos);
out.writeObject(p);
out.close();
} catch (Exception ex) {
ex.printStackTrace();
}
String base64op ="";
base64op=base64ip;
return base64op;