文件预览:移除needE参数

This commit is contained in:
mhqpx
2017-12-31 12:09:19 +08:00
committed by klboke
parent eb3d36e5fd
commit 2bbf010912
5 changed files with 16 additions and 13 deletions

View File

@@ -27,10 +27,11 @@ public class DownloadUtils {
* @param type
* @return
*/
public ReturnResponse<String> downLoad(String urlAddress, String type, String fileName, String needEncode){
public ReturnResponse<String> downLoad(String urlAddress, String type, String fileName){
ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
URL url = null;
try {
urlAddress = replacePlusMark(urlAddress);
urlAddress = encodeUrlParam(urlAddress);
// 因为tomcat不能处理'+'号,所以讲'+'号替换成'%20%'
urlAddress = urlAddress.replaceAll("\\+", "%20");
@@ -92,9 +93,12 @@ public class DownloadUtils {
* @return
*/
private String replacePlusMark(String urlAddress) {
String nonParamStr = urlAddress.substring(0,urlAddress.indexOf("?") + 1);
String paramStr = urlAddress.substring(nonParamStr.length());
return nonParamStr + paramStr.replace(" ", "+");
if (urlAddress.contains("?")) {
String nonParamStr = urlAddress.substring(0,urlAddress.indexOf("?") + 1);
String paramStr = urlAddress.substring(nonParamStr.length());
return nonParamStr + paramStr.replace(" ", "+");
}
return urlAddress;
}
/**

View File

@@ -17,8 +17,8 @@ public class SimTextUtil {
@Autowired
DownloadUtils downloadUtils;
public ReturnResponse<String> readSimText(String url, String fileName, String needEncode){
ReturnResponse<String> response = downloadUtils.downLoad(url, "txt", fileName, needEncode);
public ReturnResponse<String> readSimText(String url, String fileName){
ReturnResponse<String> response = downloadUtils.downLoad(url, "txt", fileName);
return response;
}
}