Logo Search packages:      
Sourcecode: yydebug version File versions  Download package

synchronized int jay::yydebug::yyJInputStream::read ( byte[]  b,
int  off,
int  len 
) throws IOException [inline]

byte[] buf = queue.get(0);

Definition at line 67 of file yyJInputStream.java.

References queue.

                                                                              {
      if (queue == null) throw new IOException("closed");
      while (queue.isEmpty())
        try {
            wait();
        } catch (InterruptedException ie) {
            throw new IOException("interrupted");
        }

      /// byte[] buf = queue.get(0);
      byte[] buf = (byte[])queue.get(0);
      if (buf.length == 0) return -1;

      if (buf.length <= len) {
        System.arraycopy(buf, 0, b, off, buf.length);
        queue.remove(0);
        return buf.length;
      }
      
      System.arraycopy(buf, 0, b, off, len);
      byte[] nbuf = new byte[buf.length-len];
      System.arraycopy(buf, len, nbuf, 0, nbuf.length);
      queue.set(0, nbuf); notifyAll(); // others could be waiting...
      return len;
  }


Generated by  Doxygen 1.6.0   Back to index