我这里有这个代码,它是单词搜索游戏的一部分。我试图让它在用户退出或时间结束时显示网格中存在的所有单词。那,到目前为止我已经实现了。我的问题是我还想显示存在的单词数量,所以是一个数字。我怎样才能让它在顶部显示“有(单词数)当前单词”,然后是它下面的单词。
try {
FileInputStream fstream = new FileInputStream("allWordsEn.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
int presentWords = 0;
System.out.println("There were " + presentWords + " present words. They are:");
//Read File Line By Line
while ((strLine = br.readLine()) != null)
{
if(canFind(strLine, t40))
{
presentWords++;
System.out.print(strLine + " ");
}
}
//Close the input stream
in.close();