I'm just learning Java and am tasked with reading in from a file, then reversing each word in that file (so "this file" would output as "siht elif"). I have some code here but I am getting a FileNotFoundException on compile however the file is in the proper location. Because it can't find the file, I can't see what the output is at this point, although I know it is not correct right now. Can someone provide some insight given what I have? The methods used (and parameters passed in) are required however the code within the methods is my own and obviously subject to change. Any help would be greatly appreciated.
Code:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Prog1 {
public static void main(String[] args) throws FileNotFoundException, IOException {
BufferedReader in = new BufferedReader (new FileReader("testfile.txt"));
String line = in.readLine();
in.close();
}
private static String[] getWords(String line){
String[] wordList = line.split("\\s+");
return wordList;
}
private static void reverseWords(String[] wordList){
char[] words = new char []
char[] words = wordList.toCharArray();
String word = String.valueOf(words);
}
private static String reverse (String word){
if (word.length()==0)
return "";
else return (reverse(word)+ word.charAt(0));
}
private static void printWords(String[] wordList){
String reversedList = String.valueOf(wordList);
System.out.print(reversedList);
}
}