I have a set of files like "f-1.txt" , "f-2.txt", ..... , "f-30.txt", "g-1.txt" , "g-2.txt", ..... , "g-23.txt","h-1.txt" , "h-2.txt", ..... , "h-35.txt"..etc in a folder.I want to add a few things to each of them and rename them like "f-1new.txt" , "g-2new.txt". How can I refer them in java preferably using wildcard and rename them suitably?
For a particlar file, I use BufferedReader to read its contents and Printwriter to write modified contents to a new file name.. But how can I read contents from all files, (iteratively) if the names varies too much(yet maintain order) like the ones described above?
I have refrred to this but it didnt help me with how to get the file names of each file in the array(the first answer in the post)..