public static void main(String[] args) { Dictionary dico = new Dictionary(); System.out.print("Parsing dictionary."); dico.ParseLettersValuesFile("lettervalues.txt"); dico.Parse("enable1.txt"); System.out.println("\t\t done."); Hand hand = null; try { System.out.print("Parsing hand."); Scanner scan = new Scanner(new FileReader("hand")); hand = new Hand(scan.nextLine(), dico.getLettersValues()); scan.close(); System.out.println("\t\t done."); } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println("Searching for the word (or combination of words) with the maximal value."); Word result = dico.getWordWithMaxValue(hand); System.out.println("\t\t done."); System.out.println("Writing result."); PrintWriter w; try { w = new PrintWriter("result.txt", "UTF-8"); for (String s : result.getWord().split(" ")) { w.println(s); } w.print(result.getValue()); w.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }