Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using CharMatcher.is() and CharMatcher.isNot() API.
package com.bethecoder.tutorials.guava.base_tests; import com.google.common.base.CharMatcher; public class CharMatcherIsNotTest { /** * @param args */ public static void main(String[] args) { System.out.println(CharMatcher.is('A').matches('A')); System.out.println(CharMatcher.is('A').matches('a')); System.out.println(CharMatcher.isNot('A').matches('a')); System.out.println(CharMatcher.isNot('A').matches('9')); System.out.println(CharMatcher.isNot('A').matches('#')); System.out.println(CharMatcher.isNot('A').matches('A')); } }
true false true true true false