发送地址有空格的处理

try {     String urlString = "http://www.hospimedica.com/images/stories/articles/article_images/_CC/20110328 - DJB146.gif";     URL url = new URL(urlString.replaceAll(" ", "%20"));     URLConnection connection = url.openConnection();     connection.setRequestProperty("User-agent", "Mozilla/4.0");     connection.connect();     InputStream input = connection.getInputStream();     Log.d("#####", "result: " + BitmapFactory.decodeStream(input)); } catch (MalformedURLException e) {     e.printStackTrace(); } catch (IOException e) {     e.printStackTrace(); }
其中 connection . setRequestProperty ( "User-agent" , "Mozilla/4.0" );
    这句很关键 我是通过它成功的没有他 不能成功

你可能感兴趣的:(发送)