Given two files
random_letters.txt
AABBBBB
FLOWERS
BACKGFD
TOBEACH
dictionary.txt
flowers
to
beach
back
I need to check each combination of the random_letters with dictionary to see if there is anything common. it can be a word with at least 6 characters or two words that equal at least 6 characters. Which would make it FLOWERS
or TOBEACH
.
I am having a tough time figuring out what I need to do. I can get it to work for words with 7 characters because I used strings. I understand I need to use char in order for it to work.
what I have so far:
public static void compare() {
private static String stringToWrite2 = "";
private static String[] allWords = new String[2187];
private static String[] diction = new String[79765];
private static char[][] test = new char[2187][7];
private static char[][] test2 = new char[79765][7];
public static void main(String args[])
try {
Scanner file1 = new Scanner(new File("random_letters.txt"));
Scanner file2 = new Scanner(new File("dictionary.txt"));
for(int i = 0; i < 2187; i++) {
allWords[i] = file1.next();
test[i] = allWords[i].toCharArray();
}
for(int i = 0; i < 79765; i++) {
diction[i] = file2.next();
diction[i] = diction[i].toUpperCase();
test2[i] = diction[i].toCharArray();
}
for(int i = 0; i < 2187; i++) {
for (int j = 0; j < 79765; j++) {
if(allWords[i].equals(diction[j])) {
stringToWrite2 += diction[j];
}
}
}
} catch (IOException e) {
System.out.println("could not find file");
}
System.out.println("-------------------");
System.out.println(stringToWrite2);
for(int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++)
System.out.println(test2[i][j]);
}
}}