package com.wechat.common.utils;

import java.io.File;
import java.io.FileInputStream;

import org.springframework.util.FileCopyUtils;

public class IOStreamUtils extends BaseUtils {

	/**
	 * 根据图片名称获取字节流
	 * 
	 * @param basePath
	 *            根路径
	 * @param filePath
	 *            图片路径
	 * @param fileName
	 *            图片名称
	 * @return
	 */
	public static byte[] getimagefile(String basePath, String filePath, String fileName) {
		byte[] data = null;
		try {
			// 设置文件上传路径
			String uploadPath = basePath + filePath;
			File file = new File(uploadPath, fileName);
			if (file.exists()) {
				FileInputStream fis = new FileInputStream(file);
				data = FileCopyUtils.copyToByteArray(fis);
			}
		} catch (Exception ex) {
			log.error("io异常", ex);
			return null;
		}
		return data;
	}

}
