英文:
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 72
问题
以下是翻译好的部分:
有人可以帮我解决这个问题吗?我遇到了这样的错误:
在线程“main”中的异常java.nio.file.InvalidPathException:索引72处的非法字符<:>:D:/Users/cleyeza/Desktop/document/SEC_DOC_SUBMISSION_REPORT_2020-10-0709:54:27+0800.csv
这是我的代码:
String directoryPath = AppConfig.OUTPUT_PATH.value();
File dir = new File(directoryPath);
if(!dir.exists()){
dir.mkdirs();
}
Writer writer = Files.newBufferedWriter(Paths.get(directoryPath
+ "/" + filename + ".csv"));
提前谢谢您的帮助。
英文:
can someone help me with this one, im having a error like this
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 72: D:/Users/cleyeza/Desktop/document/SEC_DOC_SUBMISSION_REPORT_2020-10-0709:54:27+0800.csv
and this is my code
String directoryPath = AppConfig.OUTPUT_PATH.value();
File dir = new File(directoryPath);
if(!dir.exists()){
dir.mkdirs();
}
Writer writer = Files.newBufferedWriter(Paths.get(directoryPath
+"/" +filename+".csv"));
thank you in advance
答案1
得分: 1
你必须从文件名SEC_DOC_SUBMISSION_REPORT_2020-10-0709:54:27+0800.csv
中删除冒号。在Windows操作系统中,冒号是一个保留字符,因此在命名文件、路径和命名空间时不允许使用任何保留字符。请查阅Windows命名约定。
英文:
You have to remove the colons from your filename SEC_DOC_SUBMISSION_REPORT_2020-10-0709:54:27+0800.csv
. It is a reserved character on Windows and you are not allowed to use any reserved character while naming Files, Paths, and Namespaces.
Checkout the Windows Naming Conventions
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论