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

jas*_*son 3 java android uri http-get

我在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>();
Run Code Online (Sandbox Code Playgroud)

                            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>();
Run Code Online (Sandbox Code Playgroud)

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;
Run Code Online (Sandbox Code Playgroud)

Pok*_*u22 7

76处的角色|可能是问题的原因.你有没有尝试用十六进制格式替换它%7C,形成这个:http://maps.googleapis.com/maps/api/geocode/json?components=locality:Spokane%7Ccountry=us%7Cadministrative_area:washington&address="+newText+"&sensor=false

还有,newText定义了吗?