// author Jef Poskanzer jef@acme.com http://www.acme.com/jef/
// Read into an array of bytes. This is a fixed version
// of java.io.InputStream.read(byte[], int, int). The
// standard version catches and ignores IOExceptions from
// below; this version sends them on to the caller.
public int read( byte[] b, int off, int len ) throws IOException
{
   if ( len <= 0 )
      {
      return 0;
      }
   int c = read();
   if ( c == -1 )
      {
      return -1;
      }
   if ( b != null )
      {
      b[off] = (byte)c;
      }
   int i;
   for ( i = 1; i < len; ++i )
      {
      c = read();
      if ( c == -1 )
         {
         break;
         }
      if ( b != null )
         {
         b[off + i] = (byte)c;
         }
      }
   return i;
}