I am working on a simple chat box between two clients that feed strings through a server. So far, I am using the ObjectInputStream in java, and I want to check if the stream currently has any objects waiting to be read. I know that the method "reader.readObject()" waits until there is an object to be sent, but is there any way to check if the input stream is currently holding a value?
There is available()
method in ObjectInputStream that returns the number of bytes that can be read from the stream, although i'm not sure how you can check if there is an object waiting to be read
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.