# Question

Formatted question description: https://leetcode.ca/all/157.html

 157	Read N Characters Given Read4

The API: int read4(char *buf) reads 4 characters at a time from a file.
The return value is the actual number of characters read.

For example, it returns 3 if there is only 3 characters left in the file.

By using the read4 API, implement the function
that reads n characters from the file.

Note:
The read function will only be called once for each test case.



# Algorithm

Read every 4, and then judge the results,

• If it is 0, it means that the buf has been read at this time, and the loop is jumped out, and the smaller value of res and n is directly returned.
• Otherwise, keep reading until n characters are read, the loop ends, and finally the smaller value of res and n is returned

Java