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

后端 未结 13 1442
一个人的身影
一个人的身影 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:15

    This can occur when filename has timestamp with colons, eg. myfile_HH:mm:ss.csv Removing colons fixed the issue.

提交回复
热议问题