SHARE
TWEET

Untitled

a guest Jan 18th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String url = "http://maps.googleapis.com/maps/api/distancematrix/xml?origins="+origin+"&destinations="+destination+"&mode=driving&sensor=false&language=en-EN&units=imperial";
  2. url = url.replaceAll(" ", "%20");
  3.    
  4. http://maps.googleapis.com/maps/api/distancematrix/xml?origins=150%20Sutter%20St%20San%20Francisco,%20CA,%20United%20States&destinations=1%20Palmer%20Sq%20E
  5. Princeton,%20NJ%2008542&mode=driving&sensor=false&language=en-EN&units=imperial
  6.    
  7. java.net.MalformedURLException: Illegal character in URL
  8.    
  9. String url = "http://...";
  10. String encodedUrl = null;
  11.  
  12. try {
  13.     encodedUrl = URLEncoder.encode(url, "UTF-8");
  14. } catch (UnsupportedEncodingException ignored) {
  15.     // Can be safely ignored because UTF-8 is always supported
  16. }
  17.    
  18. String url = "http://maps.googleapis.com/maps/api/distancematrix/xml?origins=" + URLEncoder.encode(origin, "UTF-8");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top