使用对象读取器功能读取到文件末尾

时间:2018-03-05 08:13:01

标签: java

我正在尝试读取文件中写入的对象。

ObjectInputStream objectInputStream=new ObjectInputStream(new FileInputStream("D:\\Users\\Dell-7560\\Documents\\NetBeansProjects\\Advanced Computer Networking\\src\\Experiment8\\Packets.txt"));
        Packet p = new Packet();
        while((p=(Packet) objectInputStream.readObject())!=null)
        {
            p.printDetails();
        }

这是我实现的输出。

Packet Weight : 1
Packet Data : stibulum in neque ne
Packet time value 1522079495482
Packet Weight : 2
Packet Data :  libero mattis hendr
Packet time value 1522079495482
Packet Weight : 3
Packet Data : rit in nec quam.
Packet time value 1522079495482
    at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2626)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1321)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
    at Experiment8.CreateDummyData.main(CreateDummyData.java:69)
C:\Users\Dell-7560\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)

如何在没有例外的情况下读取文件。即使用对象阅读器功能直到文件结尾。

2 个答案:

答案 0 :(得分:2)

/**********For Desktop *************/ 
@media screen and (min-width: 992px) {}

/**********For Tablet *************/
@media screen and (min-width: 768px) and (max-width: 991px) {}

/**********For Mobile *************/
@media screen and (max-width: 767px) {}

您已在媒体查询中添加了(::)两个分号,只需删除它。

还将其放在头标记中:

<meta name="viewport" content="width=device-width, initial-scale=1">

答案 1 :(得分:0)

只需删除&#34;:&#34;从下面的行:

@media screen and  (min-width: 992px) // It should like this now
@media screen and  (min-width : : 992px) // It was before like that (: :) should not twice only single (:)