B
B
Boris Khripko2017-04-03 14:35:39
Java
Boris Khripko, 2017-04-03 14:35:39

Is it possible to read the same piece of information from a DataInputStream?

Hello.
I had a breakdown. Who can tell me.
I have an InputStream inputStream which I wrap in a DataInputStream.
In it, I should receive objects in a certain sequence, which I must write to the array fields (roughly speaking, from the other side, they threw me objects that lie in the same array). I have to follow a strict sequence of objects. And if there were null cells in the array from which objects are thrown to me through the stream, then they will also be in the resulting array.
To read these objects, I have already written a method to which I pass inputStream. In it, the incoming fields are actually parsed and an object is created (it must be so by condition).
The string "\n" should serve as a marker for an empty array cell. That is, if this character comes to me in the stream, then I put null in the current position of the array in the cell. Otherwise, using the method, I read the object there.
But there is one but. I have no idea how to read this character from the stream. After all, if he is, then fine. And if it is not there, then I consider the field of the object and I will not be able to apply the method for parsing the object.
Who can tell me whether it is possible to read the same information from the stream repeatedly or can there be other methods?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2017-04-03
@BariSovich

can. wrap it in a bufferedinputstream

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question