一个关于判断从socket读取的信息是否结束的问题

szjso 2003-10-17 11:22:53
我用DataInputStream input=new DataInputStream(socket.getInputStream());
生成的input来读取返回信息,但我并不知道信息的内容,根长度,我如何判断读取信息已经结束?
...全文
127 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
szjso 2003-10-17
  • 打赏
  • 举报
回复
3x loverose
LoveRose 2003-10-17
  • 打赏
  • 举报
回复
public abstract int read() throws IOExceptionReads
the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
A subclass must provide an implementation of this method.

Returns:
the next byte of data, or -1 if the end of the stream is reached.

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧