Add index to filename for existing file (file.txt => file_1.txt)

后端 未结 4 779
孤城傲影
孤城傲影 2021-01-23 05:18

I want to add an index to a filename if the file already exists, so that I don\'t overwrite it.

Like if I have a file myfile.txt and same time myfile.

4条回答
  •  [愿得一人]
    2021-01-23 06:14

    You might also benefit from using the apache commons-io library. It has some usefull file manipulation methods in class FileUtils and FilenameUtils.

提交回复
热议问题