• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is the diffrence between readUnsignedByte() and read() of DataInputStream

 
Faiz Mohd.
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the diffrence between readUnsignedByte() and read() of DataInputStream they both are used to read a byte, then why do we require two methods?
 
Joni Salonen
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
readUnsignedByte, like all other methods specified by the DataInput interface, throws an EOFException if the end of the stream was reached. The method read doesn't throw an exception but returns -1. Both are required in DataInputStream because it is an InputStream that implements the DataInput interface (and thus must have both methods).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!