androidhttpget

private class goDb implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            new AsyncTask(){
                @Override
                protected Void doInBackground(String... params) {
                    try {
                        URL url = new URL(params[0]);
                        try {
                            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                            InputStream is = connection.getInputStream();
                            InputStreamReader isr = new InputStreamReader(is, "utf-8");
                            BufferedReader br = new BufferedReader(isr);
                            String line;
                            while ((line = br.readLine()) != null) {
                                System.out.println(line);
                            }
                            br.close();
                            isr.close();
                            is.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    } catch (MalformedURLException e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            }.execute("http://fanyi.youdao.com/openapi.do?keyfrom=testwtw&key=1422432408&type=data&doctype=json&version=1.1&q=good");
            
        }
    }

分享标题:androidhttpget
文章分享:http://bzwzjz.com/article/ppheji.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设公司 宜宾网站设计 响应式网站设计方案 成都企业网站制作 成都网站建设 四川成都网站制作 成都网站建设 网站建设方案 成都网站建设推广 企业网站建设 app网站建设 重庆手机网站建设 高端品牌网站建设 响应式网站设计 高端网站建设 网站设计 成都网站制作 营销网站建设 成都网站建设流程 成都做网站建设公司 成都网站设计 手机网站建设套餐