I am trying to search for words within a text file and replace all upper-cased with lower-cased characters. The problem is that when I use the replace All function using a regular expression I get a syntax error. I have tried different tactics, but it doesn't work. Any tips? I think that maybe I should create a replace All method that I would have to invoke, but I don't really see its use.
public static void main() throws FileNotFoundException { ArrayList<String> inputContents = new ArrayList<>(); Scanner inFile = new Scanner(new FileReader("H:\\csc8001\\data.txt")); while(inFile.hasNextLine()) { String line = inFile.nextLine(); inputContents.add(inFile.nextLine()); } inFile.close(); ArrayList<String> dictionary = new ArrayList<>(); for(int i= 0; i <inputContents.size(); i++) { String newLine = inFile.nextLine(); newLine = newLine(i).replaceAll("[^A-Za-z0-9]"); dictionary.add(inFile.nextLine()); } // PrintWriter outFile = // new PrintWriter("H:\\csc8001\\results.txt"); }