Android --http请求之HttpURLConnection

参考博客:Android HttpURLConnection 基础使用

参考博客:Android访问网络,使用HttpURLConnection还是HttpClient?

String getUrl = mUrl + "/login.ashx?type=authen&user=" + mEmail
                    + "&pwd=" + mPassword;
            URL loginUrl = null;
            InputStream in = null;
            HttpURLConnection conn = null;

            try {
                loginUrl = new URL(getUrl);
                conn = (HttpURLConnection) loginUrl.openConnection();
                in = new BufferedInputStream(conn.getInputStream());
                Scanner scanner = new Scanner(in).useDelimiter("\\A");
                String result = scanner.hasNext() ? scanner.next() : "";
                Log.e("Url请求", result);
            } catch (IOException ex){
                Log.e("Url请求 错误!", ex.toString());
            }
            return false;

GET请求模式

上一篇:groot 引入外部模板


下一篇:linux上查找文件存放地点和文件中查找字符串方法