无法用Java创建文件(IOException)

Wea*_*nds 0 java date file

我正在尝试在该目录中创建一个目录和csv文件.该目录已创建,但在创建文件时它会给出异常这是我的代码

 File dirName = new File("C:\\Umair\\Trace Bandwidth Statistics");
 if (!dirName.exists())
     dirName.mkdir();
 DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");  
        File file = new File( dirName + "\\"+ df.format(new Date()) +"_Statistics.csv"); 
        if ( !file.exists() )
            file.createNewFile();
Run Code Online (Sandbox Code Playgroud)

我得到此异常java.io.IOException:文件名,目录名或卷标语法不正确

任何的想法?

谢谢

mav*_*ato 6

:Windows的文件名中不允许使用该字符,因此无法将该df.format(new Date())部件添加到文件名中

以下是Windows的文件名规则:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx