Logo Search packages:      
Sourcecode: libjlayer-java version File versions  Download package

int javazoom::jl::decoder::Bitstream::readFully ( byte[]  b,
int  offs,
int  len 
) throws BitstreamException [inline, private]

Reads the exact number of bytes from the source input stream into a byte array.

Parameters:
b The byte array to read the specified number of bytes into.
offs The index in the array where the first byte read should be stored.
len the number of bytes to read.
Exceptions:
BitstreamException is thrown if the specified number of bytes could not be read from the stream.

Definition at line 597 of file Bitstream.java.

References javazoom::jl::decoder::BitstreamErrors::STREAM_ERROR.

Referenced by read_frame_data().

      {           
            int nRead = 0;
            try
            {
                  while (len > 0)
                  {
                        int bytesread = source.read(b, offs, len);
                        if (bytesread == -1)
                        {
                              while (len-->0)
                              {
                                    b[offs++] = 0;
                              }
                              break;
                              //throw newBitstreamException(UNEXPECTED_EOF, new EOFException());
                        }
                        nRead = nRead + bytesread;
                        offs += bytesread;
                        len -= bytesread;
                  }
            }
            catch (IOException ex)
            {
                  throw newBitstreamException(STREAM_ERROR, ex);
            }
            return nRead;
      }


Generated by  Doxygen 1.6.0   Back to index