【发布时间】:2016-12-09 16:53:14
【问题描述】:
如何在 Java 中从 Amazon 文件路径获取文件。它总是返回(文件名、目录名或卷标语法不正确)错误。如果我提供本地路径,它会完美运行。这是我的代码
FileInputStream fis;
String filePath = "https://mydomain:8080/S3DOC/?filename=/folder/DEV/Portal/sample.doc";
if(FilePath.substring(FilePath.length() -1).equals("x")){ //is a docx
System.out.println("docx");
try {
fis = new FileInputStream(new File(FilePath));
XWPFDocument doc = new XWPFDocument(fis);
XWPFWordExtractor extract = new XWPFWordExtractor(doc);
System.out.println(extract.getText());
} catch (IOException e) {
e.printStackTrace();
}
} else { //is not a docx
System.out.println("doc");
try {
fis = new FileInputStream(new File(FilePath));
HWPFDocument doc = new HWPFDocument(fis);
WordExtractor extractor = new WordExtractor(doc);
System.out.println(extractor.getText());
} catch (IOException e) {
e.printStackTrace();
}
}
错误:java.io.FileNotFoundException: https:\mydomain:8080\S3DOC\?filename=\folder\DEV\Portal\sample.doc(文件名、目录名或卷标语法不正确)
【问题讨论】: