Can I set a timeout for a InputStream's read() function?

前端 未结 1 681
忘了有多久
忘了有多久 2020-12-18 01:40

I have a DataInputStream that I obtained from a Socket. Is there any way I can set a timeout for dis.read(...)? Currently I spawn a ne

相关标签:
1条回答
  • 2020-12-18 02:20

    Not on the InputStream generally, but you can use Socket#setSoTimeout(int) to set a timeout for all read operations on the socket itself.

    0 讨论(0)
提交回复
热议问题