2016-12-09 7 views
1

JavaのAmazonファイルパスからファイルを取得する方法。常に(ファイル名、ディレクトリ名、またはボリュームラベルの構文が正しくない)エラーを返します。私が地元の道を与えれば、それは完全に働く。ここに私のコードがあるS3リンクからファイルを取得する方法 - Java

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 \ \ファイル名= \フォルダ\ DEV \ポータルの\ Sample.docが(ファイル名、ディレクトリ名、またはボリュームS3:

//バケツ/キーあなたがS3Objectを取得し、その後、InputStreamを取得

AmazonS3Client.getObject(String bucketName, String key); 

を使用することができますラベルの構文が)のような

答えて

1

S3のパスが正しくありません。

+0

ありがとうございます!出来た !! – Hari

関連する問題