在这段代码中,我对如何返回保存结果感到困惑。我尝试return saveVector;
并返回baseDirectory;
,但显然我无法将向量转换为字符串。我是编码的菜鸟,所以这里的任何帮助都将不胜感激,我希望你能把这个已经存在的代码撕成碎片。
public String add(String category, Question q) {
// Get the vector of questions from a category file
Vector<Question> Q = new Vector<Question>();
// Add the question object to the vector
Q.add(q);
// Save the vector back to the category file
ObjectOutputStream saveVector = new ObjectOutputStream(new FileOutputStream(baseDirectory));
// Return the result of the save operation
return saveVector;
}