美文网首页
连网(网站上传账户和密码)

连网(网站上传账户和密码)

作者: 谜之龙 | 来源:发表于2017-05-17 16:11 被阅读0次

    连网的工具类

    public class POST {
    
    private static String s;
    private static String explain;
    
    public static String getIntent(String web){
        try {
            URL url=new URL(web);
            Log.e("s","s");
            HttpURLConnection connection= (HttpURLConnection) url.openConnection();
            connection.setConnectTimeout(3000);
            connection.setRequestMethod("GET");
            connection.setRequestProperty("accept","*/*");
            connection.setRequestProperty("connection","Keep-Alive");
            connection.setRequestProperty("Aaccept-Charset","utf-8");
            int code = connection.getResponseCode();
            if (code==200){
                BufferedReader output=new BufferedReader(new InputStreamReader
                        (connection.getInputStream(),"UTF-8"));
                s = output.readLine();
                JSONObject json=new JSONObject(s);
                JSONObject sub=json.getJSONObject("data");
                String message=json.getString("message");
                explain = sub.getString("explain");
                Log.e("sss","explain="+explain);
    
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return explain;
    }
    }

    相关文章

      网友评论

          本文标题:连网(网站上传账户和密码)

          本文链接:https://www.haomeiwen.com/subject/mtvdxxtx.html