【发布时间】:2020-05-13 14:11:29
【问题描述】:
我正在尝试访问资源文件夹中的特定文件,获取该 uri,将其转换为 toString,然后使用该文件通过 ftp 将该文件发送到服务器。下面是我目前用来尝试的代码,但我不断收到 FileNotFoundException。如果有人能告诉我我做错了什么,或者提供另一种方法来做到这一点,那就太好了!
@Value("classpath:submitTest.txt")
private Resource res;
private String submitJcl(FTPClient ftp, String serverName) throws IOException {
FileInputStream inputStream = new FileInputStream(res.getURI().toString());
ftp.storeFile(serverName, inputStream);
return result;
}
错误:
2020-05-13 09:04:25.353 ERROR 11472 --- [nio-8443-exec-3] c.cat.pis.service.CnlLetterServiceImpl : java.io.FileNotFoundException: file:\C:\Users\mallid2\eclipse-new-PIS\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Product%20Information%20System%20(PIS)\WEB-INF\classes\submitTest.txt (The filename, directory name, or volume label syntax is incorrect)
【问题讨论】:
标签: java spring-boot file ftp