我已经看过很多不同的帖子,关于您应该以何种方式将对象序列化为文件,并且所有这些帖子在本质上都在如何做到这一点以及最佳实践是什么方面存在冲突。所以这就是我要保存的内容:
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?
}