/**
     * 获取 文件 流
     *
     * @param targetPicUrl 网络图片url
     * @return
     * @throws IOException
     */
    private InputStream getFile(String targetPicUrl) {
            InputStream inStream = null;
            try {
                URL urlConet = new URL(targetPicUrl);
                HttpURLConnection con = (HttpURLConnection) urlConet.openConnection();
                con.setRequestMethod("GET");
                con.setConnectTimeout(4 * 1000);
                inStream = con.getInputStream();    //通过输入流获取图片数据
            }catch (Exception e){
                log.error("获取图片流失败:{}",e.getMessage());
            }
            return inStream;

    }

 

posted on 2022-07-25 17:07  CccccDi  阅读(138)  评论(0编辑  收藏  举报