## com.sun.grizzly.util
Class Utils

    java.lang.Object
      com.sun.grizzly.util.Utils

    public class Utils

extends Object

Class contains set of useful operations commonly used in the framework

Author:
  Alexey Stashok, Jean-Francois Arcand

Constructor Summary
`Utils()`

Method Summary
`static byte[]` `extractBytes(ByteBuffer byteBuffer, byte startByte, byte endByte)` Return the bytes contained between the startByte and the endByte.
`static int` `findBytes(ByteBuffer byteBuffer, byte[] b)` Specialized utility method: find a sequence of lower case bytes inside a ByteBuffer.
`static int` `readWithTemporarySelector(SelectableChannel channel, ByteBuffer byteBuffer, long readTimeout)` Method reads data from `SelectableChannel` to `ByteBuffer`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Utils

    public Utils()

Method Detail

### readWithTemporarySelector

    public static int readWithTemporarySelector(SelectableChannel channel,
                                                ByteBuffer byteBuffer,
                                                long readTimeout)
                                         throws IOException

  Method reads data from `SelectableChannel` to `ByteBuffer`. If data is not immediately available - channel will be reregistered on temporary `Selector` and wait maximum readTimeout milliseconds for data.

  Parameters:
    `channel` - `SelectableChannel` to read data from
    `byteBuffer` - `ByteBuffer` to store read data to
    `readTimeout` - maximum time in millis operation will wait for incoming data
  Returns:
    number of bytes were read
  Throws:
    ``IOException`` - if any error was occured during read
    `IOException`

### extractBytes

    public static byte[] extractBytes(ByteBuffer byteBuffer,
                                      byte startByte,
                                      byte endByte)
                               throws IOException

  Return the bytes contained between the startByte and the endByte. The ByteBuffer will be left in the state it was before invoking that method, meaning its position and limit will be the same.

  Parameters:
    `byteBuffer` - The bytes.
    `startByte` - the first byte to look for
    `endByte` - the second byte to look for
  Returns:
    The byte[] contained between startByte and endByte
  Throws:
    `IOException`

### findBytes

    public static int findBytes(ByteBuffer byteBuffer,
                                byte[] b)

  Specialized utility method: find a sequence of lower case bytes inside a ByteBuffer.

Copyright © 2008 SUN Microsystems. All Rights Reserved.