try{
oout=new ObjectOutputStream(
new BufferedOutputStream(
new FileOutputStream(f)
)
);
oout.writeObject(list);//
}catch (Exception e){
e.printStackTrace();
}
//部分報錯:java.io.NotSerializableException: LogModel
所以去看這個方法對應的註解:
* @throws InvalidClassException Something is wrong with a class used by
* serialization.
* @throws NotSerializableException Some object to be serialized does not//
* implement the java.io.Serializable interface.
* @throws IOException Any exception thrown by the underlying
* OutputStream.
*/
public final void writeObject(Object obj) throws IOException
對應//是//的錯誤,所以得到解決辦法:如下,list對應的對象要實現serializable的接口。
public class LogModel implements Serializable {
}