org.apache.commons.text.WordUtils.containsAllWords() Java Code Examples

How to use containsAllWords() method in org.apache.commons.text.WordUtils class.

More Java code examples for org.apache.commons.text.WordUtils Apache Commons Text library.

Java Code Example 1 checks if the String contains all words in the given array

import org.apache.commons.text.WordUtils;

public class WordUtilsContainsAllWordsExample1 {
    public static void main(String[] args) {
        String testString = "simple solution website";
        String[] arrayOfWords = new String[] {"simple", "solution", "website"};

        boolean result = WordUtils.containsAllWords(testString, arrayOfWords);

        System.out.println(result);
    }
}
Output:

true

Java Code Example 2 checks if the String contains all words in the given array

import org.apache.commons.text.WordUtils;

public class WordUtilsContainsAllWordsExample2 {
    public static void main(String[] args) {
        String testString = "simple solution website";
        String[] arrayOfWords = new String[] {"simple", "solution"};

        boolean result = WordUtils.containsAllWords(testString, arrayOfWords);

        System.out.println(result);
    }
}
Output:

true

Java Code Example 3 checks if the String contains all words in the given array

import org.apache.commons.text.WordUtils;

public class WordUtilsContainsAllWordsExample3 {
    public static void main(String[] args) {
        String testString = "simple solution website";
        String[] arrayOfWords = new String[] {"simple"};

        boolean result = WordUtils.containsAllWords(testString, arrayOfWords);

        System.out.println(result);
    }
}
Output:

true

Java Code Example 4 checks if the String contains all words in the given array

import org.apache.commons.text.WordUtils;

public class WordUtilsContainsAllWordsExample4 {
    public static void main(String[] args) {
        String testString = "simple solution website";
        String[] arrayOfWords = new String[] {"simple", "video"};

        boolean result = WordUtils.containsAllWords(testString, arrayOfWords);

        System.out.println(result);
    }
}
Output:

false

Java Code Example 5 checks if the String contains all words in the given array

import org.apache.commons.text.WordUtils;

public class WordUtilsContainsAllWordsExample5 {
    public static void main(String[] args) {
        String testString = "simple solution website";
        String[] arrayOfWords = new String[] {"web"};

        boolean result = WordUtils.containsAllWords(testString, arrayOfWords);

        System.out.println(result);
    }
}
Output:

false

Java Code Example 6 checks if the String contains all words in the given array

import org.apache.commons.text.WordUtils;

public class WordUtilsContainsAllWordsExample6 {
    public static void main(String[] args) {
        String testString = "simple solution website";
        String[] arrayOfWords = new String[] {"web", "site"};

        boolean result = WordUtils.containsAllWords(testString, arrayOfWords);

        System.out.println(result);
    }
}
Output:

false

Java Checks if a String contains all words in array using Apache Commons Text