だから私はURLでこの文字列を使用しようとしていました:-
http://site-test.com/Meetings/IC/DownloadDocument?meetingId=c21c905c-8359-4bd6-b864-844709e05754&itemId=a4b724d1-282e-4b36-9d16-d619a807ba67&file=\\s604132shvw140\Test-Documents\c21c905c-8359-4bd6-b864-844709e05754_attachments\7e89c3cb-ce53-4a04-a9ee-1a584e157987\myDoc.pdf
このコードでは: -
String fileToDownloadLocation = //The above string
URL fileToDownload = new URL(fileToDownloadLocation);
HttpGet httpget = new HttpGet(fileToDownload.toURI());
しかし、この時点でエラーが発生します: -
java.net.URISyntaxException: Illegal character in query at index 169:Blahblahblah
少しグーグルで調べてみると、これは URL の文字 (& を推測) が原因であることがわかりました。そのため、いくつかのコードを追加したので、次のようになりました。
String fileToDownloadLocation = //The above string
fileToDownloadLocation = URLEncoder.encode(fileToDownloadLocation, "UTF-8");
URL fileToDownload = new URL(fileToDownloadLocation);
HttpGet httpget = new HttpGet(fileToDownload.toURI());
ただし、これを実行しようとすると、URL を作成しようとするとエラーが発生し、次のエラーが表示されます。
java.net.MalformedURLException: no protocol: http%3A%2F%2Fsite-test.testsite.com%2FMeetings%2FIC%2FDownloadDocument%3FmeetingId%3Dc21c905c-8359-4bd6-b864-844709e05754%26itemId%3Da4b724d1-282e-4b36-9d16-d619a807ba67%26file%3D%5C%5Cs604132shvw140%5CTest-Documents%5Cc21c905c-8359-4bd6-b864-844709e05754_attachments%5C7e89c3cb-ce53-4a04-a9ee-1a584e157987%myDoc.pdf
URL を作成するまでエンコーディングを実行できないようです使用に適しています。私はこれらすべてに特に精通していません。文字列 A を適切にフォーマットされた URL に変換し、正しい文字を置き換えて使用するために欠けているものを誰かが指摘してくれることを期待していましたか?
どんな提案でも大歓迎です!