使用replace即可。把空格全部替换为加号。
url = url.replaceAll(" ","+");
参考:https://www.cnblogs.com/jpfss/p/10037984.html