您好我正在尝试反序列化以下对象。
public class Book extends Item implements Serializable {
public Boolean isBook;
public Boolean isBookch;
private String publicationPlace;
private String publisher;
private int edition;
private String pages;
private String article;
Book(String title, String author, String year)
{
super(title, author, year);
isBook = false;
isBookch = false;
publicationPlace = " !!! Not Known !!! ";
publisher = " !!! Not Known !!! ";
edition = 1;
pages = "!!! Not Known !!!";
article = " !!! Not Known !!! ";
}
这是对象的结构,我将其序列化为....
openw("books.dat");
Date date = new Date ();
out.writeObject(date);
for(Book b : books )
out.writeObject ( b );
closew();
这几乎可以正常工作,没有任何错误。我正在尝试将其分散为...
openr("books.dat");
Date lastsaved = (Date)in.readObject();
System.out.println("last saved date : " + lastsaved.toString());
while( true )
{
Object o = in.readObject();
if(o == null )
break;
else
{
addItem((Book)o);
books.add((Book)o);
}
}
closer();
这给出了错误: java.io.InvalidClassException: Book; 没有有效的构造函数
如何解决这个问题..thanx提前...