Question: In java please you will be taking the . java file I have provided and will be implementing the three methods I have setup for
In java please
you will be taking the java file I have provided and will be implementing the three methods I have setup for you. Part One: Method : public static String convertFileToArrayString fileName This method should convert the contents of the file into an array of words. Example: Say the file contains the following content This is a file containing text, and & It becomes this is a file, containing,text,, and, & Essentially just take every sequence separated by spaces and make it an element of an array. The length of the array is equal to the total number of words. Id use the String split function Method : public static int countStringString array, String word This method should calculate the amount of a given word in an array. Example: Say you have an array containing the following content This string, contains, the, word, the And I call it with the word The This would return Method : public static int getPositionsString array, String word This method will return an array that indicates all the positions of word in the array
this is the code given
public static String convertFileToArrayString fileName throws FileNotFoundException return null; public static int countStringString array, String word return ; public static int getPositionsString array, String word return null; public static void mainString args throws FileNotFoundException TEST String file convertFileToArrayFiletxt; int countTheFile countStringfile "the"; int fileThePositions getPositionsfile "the"; System.out.printlncountTheFile; forint pos: fileThePositions System.out.printlnpos; TEST int countForFile countStringfile "for"; int fileForPositions getPositionsfile "for"; System.out.printlncountForFile; forint pos: fileForPositions System.out.printlnpos; TEST String file convertFileToArrayFiletxt; int countRoadsFile countStringfile "roads"; int fileRoadsPositions getPositionsfile "roads"; System.out.printlncountRoadsFile; forint pos: fileRoadsPositions System.out.printlnpos; TEST int countSheFile countStringfile "she"; int fileShePositions getPositionsfile "she"; System.out.printlncountSheFile; forint pos: fileShePositions System.out.printlnpos; EXPECTED RESULTS END OF TEST END OF TEST END OF TEST END OF TEST
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
