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;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.texto_1);
textView.setMovementMethod(new ScrollingMovementMethod());
textInV = findViewById(R.id.textIn);
String data = "";
StringBuffer sbuffer = new StringBuffer();
InputStream is = this.getResources().openRawResource(R.raw.fruits);
BufferedReader reader = new BufferedReader((new InputStreamReader(is)));
if (is != null)
{
try
{
while((data =reader.readLine())!=null)
{
sbuffer.append((data + "\n"));
}
is.close();
}
catch (Exception e){ e.printStackTrace();}
}
textView.setText(sbuffer);
}
}