I just can't figure out whats wrong with this code. It compiles but just outputs no answer! The desired function is for a user to enter nicegroan for example, and for the java program to run through dictionary.txt and find the longest word it can make from the user input which in this case would be ignorance. Any help would be appriciated.
import java.util.Scanner; public class countdowntwo { public static void main(String[] args){ //instantiate an instance of FileIO FileIO reader = new FileIO(); //the code below shows how to load a file String[] contents = reader.load("C:\\dictionary.txt"); //now you can process the contents of the file as a String array Scanner in = new Scanner(System.in); System.out.println("Insert your letters"); String input = in.nextLine(); char[] inputArray = input.toCharArray(); for(int i = 0; i < contents.length; i++)//loop through dictionary array { for(int j = 0; j < contents[i].length()-1; j++)//loop through contents of that array { char[] word = contents[i].toCharArray();//create a character array for each word in file for(int k = 0; k < word.length-1; k++)//loop through character array { while(k<inputArray.length)//while its less then user input { if(word[k]==inputArray[k])//if letters in word is equal to user input { word[j]=' '; for(int l = 0; l < word.length-1; l++) { if(word[l]!= ' ') { break; } else { System.out.println("The word is "+contents[i]); break; } } } } } } } } }