I have this code that reads in a scrambles and a words file. It compares both files using their canonical form and prints out the words from the words file that match a particular scrambled word. I'm looking for ways to make this quicker.public class scramble{    public static void main(String[] args) throws Exception    {        if (args.length < 2 ) die( Must pass name of input files on cmd line. );        BufferedReader scrambles = new BufferedReader( new FileReader( args[1] ) );        BufferedReader words = new BufferedReader ( new FileReader( args[0] ) );        ArrayList<String> scramblesList= new ArrayList<String>();  // default initial capacity is 10        ArrayList<String> wordList= new ArrayList<String>();        long startTime = System.currentTimeMillis();  // like clicking START on your stopwatch        while (scrambles.ready())        {             String scramble = scrambles.readLine();             scramblesList.add( scramble );         }        Collections.sort( scramblesList );        while (words.ready())        {            String word = words.readLine();            dictionaryList.add( word );        }        Collections.sort( wordList );        for(String scramble: scramblesList)        {            System.out.print(scramble +  );                for(String word: wordList)                {                if(toCanonical(scramble).equals(toCanonical(word)))                    System.out.print(word +  );                }        System.out.println();        }        long endTime = System.currentTimeMillis();  // like clicking STOP on your stopwatch        long ms = endTime-startTime;        System.out.println(Elapsed time in seconds:  + ms/1000.0 + \n); // 1 ms is a 1,000th of a second    } // END MAIN    private static void die( String errmsg )    {                System.out.println( \nFATAL ERROR:  + errmsg + \n );                System.exit(0);    }    private static String toCanonical( String word )    {        char[] array = word.toCharArray();        // #1 declare a char[] array and assign into it the return value from word.toCharArray()         Arrays.sort(array);        // #2 pass that char[] into Arrays.sort(...)        String C = new String (array);        // #3 return a new a new String that is constructed using that char[]            return C;     }}
Matching words with a scrambled word
java;array