import java.io.*; public class Test105 { // Read a text file from disk given the filename // as a String // // Return a single String consisting of each line // of the file appended together. The text should // be converted to lower case before returning. public static String readFile(String filename) { //Code used to test. Change this when the //method is implemented return "this is a small test string"; } // Split a single String of words up into a String[] // based on white space. This code is complete and // does not need changing. public static String[] split(String source) { return source.split("\\s"); } // Sort the words contained in an array of Strings // into order based on the length of the Strings. If // the Strings are equal in length then they should be // ordered alphabetically. public static void sort(String[] source) { } // Swap two elements of an array public static void swap(String[] data, int i, int j) { } // Ensure that only one copy of each word appears in // the array. Any subsequent copy of a given word should // be set to null. public static void removeDuplicates(String[] source) { } // Given an array of values that contains some null elements, // print the elements that are not null. public static void printArray(String[] source) { } //Read a file called "test.txt", store each individual //word in an array of Strings, sort the words, remove //the duplicate entries and print the list of unique //words. public static void main(String[] args) { //read in the file from disk String contents = readFile("test.txt"); //break it up into words String[] words = split(contents); //sort the words into order sort(words); //remove duplicate words removeDuplicates(words); //print the words printArray(words); } }