String text = "I don't think we're in Kansas anymore"; if(text.indexOf("Kansas") != -1){ System.out.println("Yes, the dialog contains Kansas"); }