我看到了很多关于如何将对象序列化到文件的不同帖子,它们在如何执行和最佳实践上存在冲突。所以这就是我想要保存的内容:
public class IHandler{
public double currentLoad;
public String currentPrice;
public String configArgs[];
};
我们可以假设configArgs的大小是已知的,我需要创建一个文件,以下是我目前所拥有的内容。
public static void serializeDataOut(IHandler ISH)throws IOException{
String fileName= "Test.txt";
FileOutputStream fos = new FileOutputStream(fileName);
//What do I do here?
}
public static IHandler serializeDataIn(){
//What do I do here?
}