Exception in thread “main” java.nio.file.InvalidPathException: Illegal char <:> at index 72

huangapple go评论169阅读模式
英文:

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 &quot;main&quot; java.nio.file.InvalidPathException: Illegal char &lt;:&gt; 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
				+&quot;/&quot; +filename+&quot;.csv&quot;));

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

huangapple
  • 本文由 发表于 2020年10月7日 10:06:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/64236208.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定