当前位置: 首页 > news >正文

哪些网站专门做细胞的网站建设一条龙

哪些网站专门做细胞的,网站建设一条龙,可以直接进入的网站正能量大豆网,做美国代购需要知道的网站加哥最近做第三方接口开发,对方提供的是get方式的http请求,下面加哥给大家进行了总结如何用java代码去发送http请求并获取结果。 下面是发送get请求的工具类 1.不要求携带token的方式 public static String getUrl(String tempurl,String bm) {String…

加哥最近做第三方接口开发,对方提供的是get方式的http请求,下面加哥给大家进行了总结如何用java代码去发送http请求并获取结果。

下面是发送get请求的工具类

1.不要求携带token的方式

public static String getUrl(String tempurl,String bm) {String result="";try {URL url = new URL(tempurl);InputStream is = null;URLConnection con=url.openConnection();con.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");con.setConnectTimeout(120000);con.setReadTimeout(120000);con.connect();try {is = con.getInputStream();BufferedReader reader = null;try {reader = new BufferedReader(new InputStreamReader(is,bm));String s="";String linesep = System.getProperty("line.separator");while((s = reader.readLine())!=null){result += s+linesep ;}reader.close();} catch (Exception e) {e.printStackTrace();}finally {if (reader != null) {try {reader.close();} catch (Exception e1) {}}}is.close();}catch (FileNotFoundException e2) {;}} catch (Exception e1) {e1.printStackTrace();}return result;}

下面是使用封装的好的请求工具类发送请求

public static void main(String[] args) {String str = "http://110.43.47.12:8089/system/sim?population=5&iteration=2&prediction=5&timestep=1&density=1";String sql=Get.getUrl(str,"utf-8");System.out.println(sql);}

注意请求发送后返回来的是JSON字符串,大家对其进行解析获取自己需要的数据即可。此外,还需注意第二个参数是编码格式。

2.要求携带token的方式

public static String getpage(String tempurl,String bm,String token ) {
        String result="";
        try {
            URL url = new URL(tempurl);
            InputStream is = null;
            URLConnection con=url.openConnection();
            con.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
            con.setConnectTimeout(120000);
            con.setReadTimeout(120000);
            con.addRequestProperty("x-access-token",token);
            con.connect();
            try {
                is = con.getInputStream();
                BufferedReader reader = null;
                try {
                    reader = new BufferedReader(new InputStreamReader(is,bm));
                    String s="";
                    String linesep = System.getProperty("line.separator");
                    while((s = reader.readLine())!=null){
                        result += s+linesep ;
                    }
                    reader.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }finally {
                    if (reader != null) {
                        try {
                            reader.close();
                        } catch (Exception e1) {
                        }
                    }
                }
                is.close();
            }catch (FileNotFoundException e2) {
                ;
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return result;
    }

http://www.yidumall.com/news/353.html

相关文章:

  • 课程设计做淘宝网站的目的软文案例大全300字
  • 化妆品企业网站建设开网店哪个平台靠谱
  • 飞机选做网站信息流广告投放平台
  • 自己做的网站怎么赚钱吗河南百度推广代理商
  • 本地做网站图片怎么存互联网广告销售好做吗
  • 互联网站的建设维护营销双11各大电商平台销售数据
  • 做外单要上什么网站天天seo百度点击器
  • 微网站开发平台 知乎网站优化公司
  • 用eclipce做登录网站推广的方式有哪些
  • 做网站推淘宝客百度知道下载
  • 网站建设佛山拓客科技营销型网站有哪些平台
  • 成都有没有做网站建设的如何获取热搜关键词
  • ftp给网站做备份互动营销
  • 建设党建工作网站策划搜狗搜索引擎优化论文
  • 我国政府门户网站建设成果seo技术学院
  • 网站建设好的图片google ads 推广
  • 学做美食的网站快速排名推荐
  • 企业网站如何建设流程优化二十条
  • 南山附近公司做网站建设多少钱seo软件简单易排名稳定
  • 个人商城网站制作费用如何自己创建一个网站
  • 如何外贸网络推广网站推广优化外链
  • 网站开发要花费多少钱seo外推软件
  • 鹰潭网站建设徐州seo管理
  • 怎样做带音乐的表白网站百度指数搜索
  • 做门户网站的公司有哪些google网站
  • 计算机网站建设名称营销案例100例
  • 网站布局怎么做人力资源管理师
  • 独立做网站需要学什么好看的网页设计作品
  • 用子域名可以做网站吗打开百度官网
  • 请科技公司做网站需要注意什么磁力狗在线搜索