Code example for SocketTimeoutException

0
   *         if any other I/O error occurs.  
   */ 
  void waitForIO(int ops) throws IOException {
     
    if (selector.select(channel, ops, timeout) == 0) {
      throw new SocketTimeoutException(timeoutExceptionString(channel, timeout,
                                                              ops)); 
    } 
  } 
     
  private static String timeoutExceptionString(SelectableChannel channel,
                                               long timeout, int ops) {
     
    String waitingFor;
    switch(ops) {
     
    case SelectionKey.OP_READ :
      waitingFor = "read"; break;
       
    case SelectionKey.OP_WRITE :
      waitingFor = "write"; break;