how to insert in place of space in android

后端 未结 7 1027
死守一世寂寞
死守一世寂寞 2020-12-08 19:31

I have a xml URL file in which there are white spaces i want to replace white spaces with %20.. how to do this????

SAXParserFactory spf = SAXParserFactory.ne         


        
7条回答
  •  孤城傲影
    2020-12-08 20:02

    When you build your URL you should use URLEncoder to encode the parameters.

    StringBuilder query = new StringBuilder();
    query.append("gallery=");
    query.append(URLEncoder.encode(value, "UTF-8"));
    

    If you already have the whole URL in a String or a java.net.URL, you could grab the query part and rebuild while URLEncoding each parameter value.

提交回复
热议问题