I have a program that ask the user questions and stores them into an arraylist. I want to take my text file and replace the words ending with ] with the words from my arraylist from earlier. Here is just a piece of my code where I scanner the text file and find the words ending with ] and prints them. (Sorry if my code is a little cluttered, I'm still a bit new to java.)
//Scanning the chosen story file for story and custom words
Scanner sf = new Scanner(new File("vacation.txt"));
while (sf.hasNextLine()) {
String current = sf.nextLine();
String all_words[];
all_words = current.split(" ");
List<String> mywordList = new ArrayList<String>(all_words.length);
for (String s:all_words) {
mywordList.add( s );
}
for (String s : mywordList)
{
if (s.endsWith("]"))
System.out.print( s + " " );