Readfully (byte[] b) is an adaptive solution to read the number of bytes in the stream problem (of course, determined by the number of arguments byte), there is read full, the end of the stream will automatically exit the block, see the JDK Help

Source: Internet
Author: User
readfully
readfully (byte[] b)
               Throws IOException
Reads some bytes from a input stream and stores them into the buffer array B. The number of bytes read is equal to the length of B.

This method blocks until one of the following conditions occurs:

B.length bytes of input data is available, with which case a normal return is made. End of file is detected, in which case an eofexception is thrown. An I/O error occurs, in which case a ioexception other than Eofexception is thrown.

If B is null, a nullpointerexception is thrown. Ifb.length is zero and then no bytes is read. Otherwise, the first byte read is stored to elementb[0], the next one into b[1], and so on. If an exception was thrown from the This method, then it could be, some and not all bytes ofb had been updated with data fro M the input stream.

Parameters: b-the buffer into which, the data is read. Throws: Eofexception-if This stream reaches the end before reading all the bytes. Ioexception-if an I/O error occurs.

Also a little parameter off to note: Off is the offset that represents the starting position of the destination byte array

void readfully (byte[] B, int off, int len)
Read the Len bit from the stream and save it to B (starting from the index off).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.