What are possible reasons for java.io.IOException: “The filename, directory name, or volume label syntax is incorrect”

后端 未结 13 1445
一个人的身影
一个人的身影 2020-12-10 02:12

I am trying to copy a file using the following code:

File targetFile = new File(targetPath + File.separator + filename);
...
targetFile.createNewFile();
file         


        
13条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 03:07

    Try adding some logging to see exactly what is the name and path the file is trying to create, to ensure that the parent is well a directory.

    In addition, you can also take a look at Channels instead of using a loop. ;-)

提交回复
热议问题