package com.zm.order.tool.server.utils;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

/**
 * @Description IO工具类
 * @Author: ph
 * @Date: 2019/10/30 16:21
 */
public class IoUtils {

    public static byte[] toBytes(InputStream input) throws Exception {
        byte[] data = null;
        try {
            ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
            byte[] b = new byte[1024];
            int read;
            while ((read = input.read(b)) > 0) {
                byteOut.write(b, 0, read);
            }
            data = byteOut.toByteArray();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            input.close();
        }
        return data;
    }
}