【发布时间】:2017-08-07 14:25:42
【问题描述】:
我从客户端上传了一个 csv 文件,我想在服务器端创建这个文件。
这是我的功能
public void uploadFile(FileUploadEvent e) throws IOException{
UploadedFile uploadedCsv=e.getFile();
String filePath="//ipAdress:/home/cg/Temp/input/ressource.csv";
byte[] bytes=null;
if(uploadedCsv != null){
bytes=uploadedCsv.getContents();
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
String filename = FilenameUtils.getName(uploadedCsv.getFileName());
stream.write(bytes);
stream.close();
}
}
当我想写文件时,我得到了这个异常(没有这样的文件或目录)
SEVERE: java.io.FileNotFoundException: /ipAdress:/home/cg/Temp/input/ressource.csv (No such file or directory)
知道在服务器上创建了/home/cg/Temp/输入路径。
【问题讨论】:
-
哪些机器是Linux?客户端?服务器?两者都有?
-
@StephenC 服务器机器是 Linux 并且客户端可以通过 Web 浏览器与任何机器进行交互
-
在那种情况下......你为什么要在 Linux 上使用 Windows UNC 路径名语法? Linux 不支持 UNC 路径。
-
@StephenC 我使用的文件在服务器上的路径都是。路径是ipAdress/home/cg/Temp/input/
-
那么在您的示例中,该冒号在路径名中的作用是什么?并在错误消息中?