我有一个包含大约50个java类/文件的项目(这50个文件包括JSP和Java文件)。在这个文件中,我编写了代码来在我的JSP页面上显示abc.jpg图像。现在我想编写一个java程序,它将在我的项目中用xyz.jpg图像替换所有abc.jpg图像。我不知道如何做到这一点。还建议是否有任何免费工具可以做同样的事情。
答案 0 :(得分:0)
您要执行的操作将使用以下步骤完成。请注意,您可以在不同的帖子中找到有关StackOverflow本身每个步骤的信息:
1. Create a traversal policy for a directory in which all files are present, to get path of all .java and .jsp files.
2. Read all files one-by-one and write its content to another temporary file line by line.
3. While reading individual line, check whether it contains the name of .jpg file whose name you want to update. If yes the replace the name with new name and write the current updated line in temporary file.
4. Once the file reading is completed, delete the original file and rename the temporary file to original one.
5. Now you will have a same file with updated names of .jpg files.
6. Repeat the steps from 2-5 until all files are read and write.
希望这会有所帮助。是的,你必须在SO本身搜索这些方法。 : - )