Having trouble writing a method to accomplish this, have the basic outline of the method but just need some pointers/help accomplishing this.
public static String [] readFileAndReturnWords(String filename){
//create array
//read one word at a time from file and store in array
//return the array
}
This is what I have so far:
public static String readFileAndReturnWords(String filename){
String[] temp = new String[];
//connects file
File file = new File(filename);
Scanner inputFile = null;
try{
inputFile = new Scanner(file);
}
//When arg is mistyped
catch(FileNotFoundException Exception1) {
System.out.println("File not found!");
System.exit(0);
}
//Loops through a file
if (inputFile != null) {
try { //I draw a blank here
I understand that some .next and .hasNext calling is in order, I just am not sure how to use these particular methods in the context of the problem.