Java File.renameTo(File) not working

前端 未结 3 2051
名媛妹妹
名媛妹妹 2021-01-22 09:39

I\'m trying to list a directory\'s contents, and rename certain files.

public void run(String dirName) {
    try {
        File parDir = new File(dirName);
              


        
3条回答
  •  [愿得一人]
    2021-01-22 10:15

    f.getName(); only returns the name of the folder, not the full path. So subbedName becomes a relative path file. Try something with f.getCanonicalPath() instead.

提交回复
热议问题