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

后端 未结 13 1463
一个人的身影
一个人的身影 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条回答
  •  Happy的楠姐
    2020-12-10 02:52

    Here is the test program I use

    import java.io.File;
    public class TestWrite {
    
        public static void main(String[] args) {
            if (args.length!=1) {
                throw new IllegalArgumentException("Expected 1 argument: dir for tmp file");
            }
            try  {
                File.createTempFile("bla",".tmp",new File(args[0]));
            } catch (Exception e) {
                System.out.println("exception:"+e);
                e.printStackTrace();
            }
        }
    }
    

提交回复
热议问题