-1

I'm writing a program to calculate the probability of getting a 'bingo' on your rack in Scrabble from your rack. I'm at the very primitive stages and haven't got down to writing the code yet. However, I have started working on the logic.

The issue I'm having is this. I have a.txt file that serves as a dictionary to judge words against in Scrabble. It is called the CSW-12 dictionary and a direct download to the .txt that I am using can be found here.

Typically, a program called Zyzzyva is used to access the words. A link to download that program can be found here.

Okay, so now out of this .txt, I need to input ONLY ALL 7 letter words. And just the words, without the meaning. So that would mean taking the word and then skipping the line when I hit a space I guess.

I am relatively new to Java and only know a little about it. I have no idea how to input data from a external file like a .txt much less how to input only excerpts from it.

Any help would be greatly appreciated. And I'd much rather you teach me how to do said task than do it for me.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199

1 Answers1

1

You can search on here for how to read the file; there are many questions on that in Java, but the relevant classes are FileReader and BufferedReader.

You can find the first space on the line with indexOf(' ') and, if it is at offset 7 (the eighth character), get the first seven characters with substring(0, 7). Since the words are sorted in ascending length, as soon as the first space is at offset 8 you can stop reading, rather than going to the end of the file.

David Conrad
  • 15,432
  • 2
  • 42
  • 54