code: private Map<String, String> readEvent() throws IOException {
          Map<String, String> map = new HashMap<>();
          ByteBuffer b;
          synchronized (this) {
              b = buffer;
              if (b == null) {
                  return map;
              }
          }
          int length = _readEvent(fd, b);
          synchronized (this) {
              if (buffer == null) {
                  return map;
              }
              int propertiesOffset = _getPropertiesOffset(buffer);
              int propertiesLength = _getPropertiesLength(buffer);
              int propertiesEnd = propertiesOffset + propertiesLength;
              if (length < propertiesEnd) {
                  throw new IOException("Mismatched property segment length");
              }
              buffer.position(propertiesOffset);
              // Data read from the udev monitor is in the form of a list of
              // lines separated by null bytes.
              // Each line defines a key/value pair, with the
              // format: <key>=<value><null terminator>
              StringBuffer key = new StringBuffer();
              StringBuffer value = new StringBuffer();
              nextKey: while (buffer.position() < propertiesEnd) {
                  key.setLength(0);
                  value.setLength(0);
                  boolean readKey = false;
                  while (buffer.position() < length && !readKey) {
                      char ch = (char) buffer.get();
                      switch (ch) {
                          case '\000': // no value on this line
                              map.put(key.toString(), "");
                              continue nextKey;
                          case '=':
                              readKey = true;
                              break;
                          default:
                              key.append(ch);
                      }
                  }
                  while (buffer.position() < propertiesEnd) {
                      char ch = (char) buffer.get();
                      switch (ch) {
                          case '\000':
                              map.put(key.toString(), value.toString());
                              continue nextKey;
                          default:
                              value.append(ch);
                      }
                  }
              }
              buffer.clear();
          }
          return map;
      }
docs: Reads data from the udev monitor. Blocks until data is available