code: public static boolean matches(String text, String pattern) {
          if (text == null) {
              throw new IllegalArgumentException("text cannot be null");
          }
  
          text += '\0';
          pattern += '\0';
  
          int N = pattern.length();
  
          boolean[] states = new boolean[N + 1];
          boolean[] old = new boolean[N + 1];
          old[0] = true;
  
          for (int i = 0; i < text.length(); i++) {
              char c = text.charAt(i);
              states = new boolean[N + 1]; // initialized to false
              for (int j = 0; j < N; j++) {
                  char p = pattern.charAt(j);
  
                  // hack to handle *'s that match 0 characters
                  if (old[j] && (p == WILDCARD))
                      old[j + 1] = true;
  
                  if (old[j] && (p == c))
                      states[j + 1] = true;
                  if (old[j] && (p == WILDCARD))
                      states[j] = true;
                  if (old[j] && (p == WILDCARD))
                      states[j + 1] = true;
              }
              old = states;
          }
          return states[N];
  
      }
docs: Performs a wildcard matching for the text and pattern provided.
  
  @param text
  the text to be tested for matches.
  
  @param pattern
  the pattern to be matched for. This can contain the wildcard
  character '*' (asterisk).
  
  @return <tt>true</tt> if a match is found, <tt>false</tt> otherwise.