I moved the array inside the try / catch and used a JSR-223 (Beanshell) Step. I was able to iterate over a set of files and replace @@CURRENT_DATE@@ with today's date in one of my files. Is there a reason this will not work for you?
import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
try {
File file = new File("C:\\Lisa\\Projects\\Parse");
File[] filenames = file.listFiles();
for(File file1 : filenames ) {
BufferedReader reader = new BufferedReader(new FileReader(file1));
String line = "";
String oldtext = "";
while((line = reader.readLine()) != null) {
oldtext += line + "\r\n";
}
reader.close();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Calendar c=Calendar.getInstance();
Date d=c.getTime();
String Track_date=format.format(d);
String newtext = oldtext.replaceAll("@@CURRENT_DATE@@", Track_date);
System.out.println("CHkText"+newtext);
FileWriter writer = new FileWriter(file1);
writer.write(newtext);
writer.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;