package com.gic.haoban.manage.service.util;

import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;

import java.io.InputStream;
import java.net.URL;

import static org.slf4j.LoggerFactory.getLogger;

/**
 * Created 2021/4/16.
 *
 * @author hua
 */
public class CommonUtil {
    private static final Logger logger = getLogger(CommonUtil.class);

    /**
     * 获取字符串
     *
     * @param url
     * @return
     */
    public static byte[] getFileByte(String url) {
        try (InputStream in = new URL(url).openStream()) {
            return IOUtils.toByteArray(in);
        } catch (Exception e) {
            logger.info("【异常】{} ,{},{}" , e.getMessage(), e , url);
        }
        return null;
    }
    
    public static void main(String[] args) {
        getFileByte("https://jhdm-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-cce7cc3de0bf48cebf16fb5c65f4ae9c.jpg?imageView2/format/jpg/q/50?imageView2/2/w/1440/h/1080") ;
        System.out.println(1);
    }

}