简体   繁体   English

使用 Object Reader 函数读取到文件末尾

[英]Using Object Reader function to read till end of file

I am trying to read the objects written in a file.我正在尝试读取写入文件的对象。

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();
        }

This is the output I acheive.这是我实现的输出。

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)

How to read the file without the exception.如何无一例外地读取文件。 ie till end of file using the object reader funtion.即使用对象读取器功能直到文件结束。

/**********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) {}

You have added (::) two semicolon in media query, just remove that.您在媒体查询中添加了 (::) 两个分号,只需将其删除即可。

Also put this in the head tag:也把它放在 head 标签中:

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

Just remove the ":" from below line:只需从下面的行中删除“:”:

@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 (:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM