我们将文件上传到Amazon AWS S3服务器并使用java类文件中的文件url来提供下载文件的功能。
如果我将文件上传为“ Test Automated Report Sheet.pdf ”(包含单词之间的空格),那么该网址为
https://s3.amazonaws.com/cdn.generalsentiment.com/MVR/reports/Test+Automated+Report+Sheet1.pdf
我正在获取ArrayIndex Out of bound异常,因为url包含'+'符号,因此我再次用空格替换'+'符号。这是执行此操作的代码。 我正在使用
String reportURL = mediaValueReport.getReportFileURL().replace('+', ' ');
这种做法是否正常,或者我可以用更优的方式写出来。