String url = "https://img3.doubanio.com/view/status/l/public/103861781-665301078817f01.jpg";
       //创建restTemplate对象
        org.springframework.web.client.RestTemplate restTemplate = new org.springframework.web.client.RestTemplate();
        /**
         * 请求地址
         * 请求方式
         * 请求实体类
         * 请求返回类型
         */
        ResponseEntity<byte[]> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, byte[].class);
        //获取entity中的数据
        byte[] body = responseEntity.getBody();
        //创建输出流  输出到本地
        FileOutputStream fileOutputStream = new FileOutputStream(new File("F:\\fuwuqi\\1.jpg"));
        fileOutputStream.write(body);
        //关闭流
        fileOutputStream.close();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2021-09-03
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-13
  • 2021-10-17
  • 2022-12-23
  • 2021-07-16
  • 2022-01-19
  • 2022-12-23
相关资源
相似解决方案