Check exact word in scrabble words list

I have a Scrabble Clock with a verification tool inside. The verification word space looks in green or red if the word that I check is in the list.

The thing is, if I use sbuffer.toString().contains, and write a word like ABA, the word space looks in green though ABA is not in the list, but ABAC, ABACA are in the list.

I would like to know how I can implement a condition in my code to check the exact complete word.

I've researched regex, boundary and matches, but I couldn't find a line code that words in my code.

Here is my code until now.

public class MainActivity extends AppCompatActivity {

    TextView textView;
    TextView textInV;

    protected void onCreate(Bundle savedInstanceState) {

        textView = findViewById(;
        textView.setMovementMethod(new ScrollingMovementMethod());
        textInV = findViewById(;

        String data = "";
        StringBuffer sbuffer = new StringBuffer();

        InputStream is = this.getResources().openRawResource(R.raw.fruits);

        BufferedReader reader = new BufferedReader((new InputStreamReader(is)));

        if (is != null)
                while((data =reader.readLine())!=null)
                    sbuffer.append((data + "\n"));


            catch (Exception e){ e.printStackTrace();}


As @Ashutosh KS has already mentioned, String.contains is not really what you are looking for in this case: You want to check if two strings are identical, not if one contains the other.

The Java String class contains a few methods that you can use to compare the content of two strings, of which you can choose accordingly to match your exact use case:

  1. contentEquals(CharSequence cs) and contentEquals(StringBuffer sb) both check if the passed string representation's content matches the current one.
  2. equals(Object str) is similar to contentEquals in that it makes an exact comparison between both strings, however it also checks to make sure that the passed object is in fact a string.
  3. equalsIgnoreCase(String anotherString), as the name implies, will do a check while ignoring the string case.

These are the 'proper' ways to compare two strings exposed by the native API, so while it is absolutely possible to use other methods, it is a good idea to stick to these.

Scrabble Cheat, Use our free Scrabble word-finder with blanks to unscramble words, cheat Solver tools let you unscramble words, finder searches can help you solve specific problems, with special championship or tournament rules and many different examples You can also check the word against the official Hasbro Scrabble page. Check words in Scrabble Dictionary and make sure it's an official scrabble word. Use this Scrabble® dictionary checker tool to find out whether a word is acceptable when playing scrabble. When you enter a word and click on Check Dictionary button, it simply tells you whether it's valid or not in scrabble word game.

The contains method on a string tests whether the target is contained as a substring; if ABAC is contained as a substring then so is ABA, since ABA is a substring of ABAC and hence it is also a substring of any string which ABAC is a substring of. Therefore, it is not logically possible for the String.contains method to return true for ABAC and false for ABA.

You want to test if the target is one of the elements of a collection of strings, so you should use contains on a collection of strings, not on a string. The best choice is a HashSet, since this performs membership tests in O(1) time on average.

> import java.util.*;
> Set<String> allowed = new HashSet<>();
> allowed.add("ABAC");
> allowed.add("ABACA");
> allowed.contains("ABA")
> allowed.contains("ABAC")

Scrabble Word Finder, Scrabble Word Finder from YourDictionary is the perfect word finder for playing the new word game Scrabble GO. Score more points and win more often with our free Scrabble cheat tool. hit that search button, be sure to double-check the selected Game Dictionary. Want to be more specific in the words you want to find? Scrabble Word Finder Use this Word Finder & Unscrambler for Scrabble, Words with Friends, and other word games. Find words by entering letters into the Unscrambler or choose a word list below. Find the best scoring words with this Word Finder from

StringBuffer's contains() check if the given string is a substring of the text in the sbuffer. That means, it will output true for searching "ABC" in "ABC", "ABCBC", "ZABC", "ZABCBC"...

If you want to search for a complete word in the sbuffer, then you can look for "\n" + "ABC" + "\n" since you're adding "\n" when adding words to sbuffer: sbuffer.append((data + "\n"));. But, you must also initialize sbuffer with "\n": StringBuffer sbuffer = new StringBuffer("\n");.

sbuffer.toString().contains("\n" + "ABC" + "\n"); // this will do the trick

Test code:

class Main {
  public static void main(String[] args) {
    StringBuffer sbuffer = new StringBuffer("\n");
    StringBuffer sbuffer2 = new StringBuffer("\n");

    sbuffer.append("ABC" + "\n");
    sbuffer.append("ABCBC" + "\n");
    sbuffer.append("ZABC" + "\n");
    sbuffer.append("ZABCBC" + "\n");

    System.out.println("Is ABC in sbuffer = " + sbuffer.toString().contains("\n" + "ABC" + "\n"));

    sbuffer2.append("ABCBC" + "\n");
    sbuffer2.append("ZABC" + "\n");
    sbuffer2.append("ZABCBC" + "\n");

    System.out.println("Is ABC in sbuffer2 = " + sbuffer2.toString().contains("\n" + "ABC" + "\n"));

Test output:

Is ABC in sbuffer = true
Is ABC in sbuffer2 = false

Scrabble Dictionary & Scrabble GO Helper, The Scrabble GO Dictionary from YourDictionary is the perfect word finder for playing the The word list that WordFinder curates for you will help you to make sure you always To use this feature, just check “Exact Match” before you search. Check exact word in scrabble words list. I have a Scrabble Clock with a verification tool inside. The verification word space looks in green or red if the word that I check is in the list. The thing is, if I use sbuffer.toString ().contains, and write a word like ABA, the word space looks in green though ABA is not in the list, but ABAC, ABACA are in the list.

Now i have this, and works, but i have a file with the words, and i would like to add the files in the diccionario.

But i don't know how to read the file. I have try bufferread, but i need try/catch, and not works....

Some other solutions....


boton2.setOnClickListener(new View.OnClickListener()

           String content;
           @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
            public void onClick(View view)
                HashSet<String> diccionario = new HashSet<String>();
                //Adding elements to HashSet



Scrabble Dictionary, Use this Scrabble� dictionary checker tool to find out whether a word is acceptable when playing scrabble. When you enter a word and click on Check� 50 Scrabble Words to Win With (Infographic) You might already be an expert Scrabble word finder, sitting next to your Scrabble dictionary and looking up the definition whenever you come across a word you don’t know, but an essential piece of the game is something unrelated to your vocabulary: the strategy.

The Free Dictionary Word Finder, The Free Dictionary Word Finder | Scrabble Word Unscrambler and Words With Friends Cheat Dictionary. Enter a word to see if it's playable (up to 15 letters). Enter any letters to see what words can be formed from them. Use up to two "?" wildcard characters to represent blank tiles or any letter.

Design215 Word Finder, Find words for Scrabble, crossword puzzles, and other word games. find words containing the letters "c", "a", and "t", in any order, like "cadet", "exact", and "teach" . The second word list is for spell checking documents. The transition from the 2015 version of the Collins Scrabble Tournament & Club Word List (hereinafter referred to as CSW15) to the 2019 version (hereinafter referred to as CSW19) involves 2862 new words in total, of which 1258 of length 2 to 9 letters, with 617 of length 2 to 8 letters.

Find Words that Contain Some Letters in Them - Online Tool, Tool to search words that contain a given letter or sequence of letters, pattern search or suit List words that contains some letters; More criteria; How to find words containing some letters? This exact consecutive letters' pattern (joker *-? allowed) To find a word with letters shuffled in any order, use the anagram solver. Official Tournament and Club Word List, 2nd Edition (OWL2) by Merriam-Webster.This is the official word source for tournament SCRABBLE players in North America. It includes all of the words listed in the OSPD4, with the addition of 9-letter words, inflections, and expurgated words from the OSPD4.

  • There are ~171,000 words in the English language, so while it's definitely a good idea to use a data structure with O(1) access, it's not strictly necessary here.
  • That depends how many words you want to check. If you're writing a Scrabble AI which tries to maximise its score by trying many possible options, then O(n) membership tests will probably not be good enough. But regardless of time complexity, the point is that substring containment is logically the wrong thing to check for.
  • To play devils advocate, if you wanted the best performance while searching (as an AI might do), it would make more sense to use a tree structure, where each branch is the next letter in a word.
  • Yes in a Scrabble check words, there are thousands of words. can i input a .txt ina hashset to check the word...?
  • You open the file, read the words, and insert each word into the HashSet instead of writing them to a StringBuffer. Even if you have 200,000 words, it will still only take a few megabytes of memory.
  • @kaya3 Thanks for the tip; I updated the answer accordingly.
  • Please check this answer. And mark it as accepted if it helps you. :)
  • This way, works, but only with the first word of the list.
  • @ddaudiosolutions It works for every word - if it's first, in the middle, or the last word in the list. Are you following my example correctly? That is, adding "\n" to StringBuffer on initialization, adding "\n" with every insert, and checking for "\n" + WORD + "\n". I just tested it: