在Java中,如果一个文件为空文件,可以在里面读取串行化的东西吗?
比如这样:Bookbook=newBook();FileInputStreamfile=newFileInputStream("book.txt");ObjectInpu...
比如这样:
Book book = new Book();
FileInputStream file = new FileInputStream("book.txt");
ObjectInputStream ois = new ObjectInputStream(file);
book = (Book) ois.readObject();
ois.close;
请问,如果上面的book.txt为空文件,可以这样吗? 展开
Book book = new Book();
FileInputStream file = new FileInputStream("book.txt");
ObjectInputStream ois = new ObjectInputStream(file);
book = (Book) ois.readObject();
ois.close;
请问,如果上面的book.txt为空文件,可以这样吗? 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询