当读取序列化文件时,如果文件是空的,将会抛出异常,该如何解决。
我的异常:java.io.EOFExceptionatjava.io.ObjectInputStream$PeekInputStream.readFully(Unknow...
我的异常:
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at utilitlybl.IOHelper.readFile(IOHelper.java:10)
at stockdata.StockListDataController.readFile(StockListDataController.java:163)
at stockdata.StockListDataController.getWarningList(StockListDataController.java:35)
at stockdata.StockListDataController.addWarningList(StockListDataController.java:143)
at stockdata.StockListDataController.main(StockListDataController.java:181)
Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to java.util.ArrayList
at stockdata.StockListDataController.getWarningList(StockListDataController.java:35)
at stockdata.StockListDataController.addWarningList(StockListDataController.java:143)
at stockdata.StockListDataController.main(StockListDataController.java:181)
当,我先有序列化对象写入文件时,便是正常的读取,这样的问题应该如何解决,高分悬赏,求高手帮忙 展开
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at utilitlybl.IOHelper.readFile(IOHelper.java:10)
at stockdata.StockListDataController.readFile(StockListDataController.java:163)
at stockdata.StockListDataController.getWarningList(StockListDataController.java:35)
at stockdata.StockListDataController.addWarningList(StockListDataController.java:143)
at stockdata.StockListDataController.main(StockListDataController.java:181)
Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to java.util.ArrayList
at stockdata.StockListDataController.getWarningList(StockListDataController.java:35)
at stockdata.StockListDataController.addWarningList(StockListDataController.java:143)
at stockdata.StockListDataController.main(StockListDataController.java:181)
当,我先有序列化对象写入文件时,便是正常的读取,这样的问题应该如何解决,高分悬赏,求高手帮忙 展开
3个回答
展开全部
try catch,OVER
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
还以为是C#,java已经不懂了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-12-15
展开全部
捕获异常不就OK了吗
追问
捕获异常,但是我要求的是可以正常运行,就是在空文件的情况下也可以不产生异常的解决办法
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询