http连接中的错误java.lang.IllegalArgumentException:索引76处的查询中的非法字符

我在http连接java.lang.IllegalArgumentException中收到错误:索引76处的查询中出现非法字符.
尝试了所有3个例子.无法解决它.Tried url_encode但它没有采取组件:地方部分考虑.我如何使这个网址工作.谢谢提前.

BufferedReader in = null;

            HttpClient httpclient = new DefaultHttpClient();

            HttpGet request = new HttpGet();
            URI website = new URI("http://maps.googleapis.com/maps/api/geocode/json?components=locality:Spokane|country=us|administrative_area:washington&address="+newText+"&sensor=false");
            request.setURI(website);
            HttpResponse response = httpclient.execute(request);
            in = new BufferedReader(new InputStreamReader(
                    response.getEntity().getContent()));

            String line = in.readLine();

            data = line;
            suggest = new ArrayList<String>();

                            String uri =("http://maps.googleapis.com/maps/api/geocode/json?components=locality:Spokane|country=us|administrative_area:washington&address="+newText+"&sensor=false");

                            uri=URLEncoder.encode(uri,"UTF-8");

                            HttpClient hClient = new DefaultHttpClient();
                            HttpGet hGet = new HttpGet(uri);
                            ResponseHandler<String> rHandler = new BasicResponseHandler();
                            data = hClient.execute(hGet,rHandler);
                            suggest = new ArrayList<String>();

String urlstr="http://maps.googleapis.com/maps/api/geocode/json?";
                String str_parameters = "components=locality:Spokane|country=us|administrative_area:washington";
                String encodedparams = URLEncoder.encode(str_parameters,"UTF-8")+"&address="+URLEncoder.encode(newText, "UTF-8")+"&sensor="+URLEncoder.encode("false", "UTF-8");

                String str_finalurl=urlstr+encodedparams;

解决方法:

76处的字符是|,这可能是问题的原因.您是否尝试使用十六进制格式替换它,形成以下内容:http://maps.googleapis.com/maps/api/geocode/json?component = locality:Spokane | country = us | adminiare :: swashington& address =“newText “&安培;传感器=假?

是否定义了newText?

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...