我得到以下异常:
D:\ Try\folder\filename_1_06_09_2014_12:46:18.txt(文件名,目录名或卷标语法不正确)
在此处使用时间戳重命名文件名时:
for (int i = 0; i < children.length; i++) {
String fileName = new SimpleDateFormat("MM_dd_yyyy_hh:mm:ss").format(new Date());
copyDirectory(new File(sourceLocation, children[i]), new File(targetLocation, files+"_"+fileName+".txt"));
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚我在Windows文件名中使用无效字符的位置.有什么建议吗?
小智 22
您不能使用冒号:在Windows中创建文件.如果您绝对需要时间戳,那么您也可以尝试为它们添加下划线.
您不能在Windows文件系统上的文件名中使用冒号,它们只能用于将驱动器与路径的其余部分分开:
D:\Try\folder\filename_1_06_09_2014_12:46:18.txt Issue is here ------------------------^--^
| 归档时间: |
|
| 查看次数: |
40580 次 |
| 最近记录: |