Class AudioInputStream

An audio input stream is an input stream with a specified audio format and
length. The length is expressed in sample frames, not bytes.
Several methods are provided for reading a certain number of bytes from
the stream, or an unspecified number of bytes.
The audio input stream keeps track of the last byte that was read.
You can skip over an arbitrary number of bytes to get to a later position
for reading. An audio input stream may support marks. When you set a mark,
the current position is remembered so that you can return to it later.

The AudioSystem class includes many methods that manipulate
AudioInputStream objects.
For example, the methods let you:

obtain an
audio input stream from an external audio file, stream, or URL

AudioInputStream

Constructs an audio input stream that reads its data from the target
data line indicated. The format of the stream is the same as that of
the target data line, and the length is AudioSystem#NOT_SPECIFIED.

read

Reads some number of bytes from the audio input stream and stores them into
the buffer array b. The number of bytes actually read is
returned as an integer. This method blocks until input data is
available, the end of the stream is detected, or an exception is thrown.

This method will always read an integral number of frames.
If the length of the array is not an integral number
of frames, a maximum of b.length - (b.length % frameSize)
bytes will be read.

available

Returns the maximum number of bytes that can be read (or skipped over) from this
audio input stream without blocking. This limit applies only to the next invocation of
a read or skip method for this audio input stream; the limit
can vary each time these methods are invoked.
Depending on the underlying stream,an IOException may be thrown if this
stream is closed.