从阿里云下载图片到本地

复制代码
  @GetMapping(value = "exportImage")
    public void exportImage(){
        try {
            URL url = new URL("http://jianxin-picture.oss-cn-hangzhou.aliyuncs.com/image-file-c500574c-c8a0-42cf-8004-1a248bb9af4e");
            BufferedInputStream in = new BufferedInputStream(url.openStream());

            File file2 = new File("检验.jpg");
            FileOutputStream out = new FileOutputStream(file2);
            int t;
            while ((t = in.read()) != -1) {
                out.write(t);
            }
            out.close();
            in.close();


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
复制代码

 

posted @   高富贵  阅读(148)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
点击右上角即可分享
微信分享提示