package com.hzs.third.pay.jdpay.util;

import org.springframework.core.io.ClassPathResource;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class FileUtil {

    public FileUtil() {
    }

    public static byte[] readFile(String filename) {
        ClassPathResource classPathResource = new ClassPathResource(filename);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        BufferedInputStream in = null;
        try {
            in = new BufferedInputStream(classPathResource.getInputStream());
            byte[] buffer = new byte[1024];
            int len;
            while (-1 != (len = in.read(buffer, 0, 1024))) {
                bos.write(buffer, 0, len);
            }
            return bos.toByteArray();
        } catch (IOException var21) {
            var21.printStackTrace();
        } finally {
            try {
                if (null != in) {
                    in.close();
                }
            } catch (IOException var20) {
                var20.printStackTrace();
            }
            try {
                bos.close();
            } catch (IOException var19) {
                var19.printStackTrace();
            }
        }
        return null;
    }

}
