Reads audio data from the data line's input buffer. The requested number of bytes is read into the specified array, starting at the specified offset into the array in bytes. This method blocks until the requested amount of data has been read. However, if the data line is closed, stopped, drained, or flushed before the requested amount has been read, the method no longer blocks, but returns the number of bytes read thus far.
The number of bytes that can be read without blocking can be ascertained using the available
method of the DataLine
interface. (While it is guaranteed that this number of bytes can be read without blocking, there is no guarantee that attempts to read additional data will block.)
The number of bytes to be read must represent an integral number of sample frames, such that:
[ bytes read ] % [frame size in bytes ] == 0
The return value will always meet this requirement. A request to read a number of bytes representing a non-integral number of sample frames cannot be fulfilled and may result in an IllegalArgumentException.