package com.ifish.util;

import java.io.File;
import java.io.IOException;

import org.springframework.web.multipart.MultipartFile;

/**
 * 文件处理工具类
 * @author Administrator
 *
 */
public class IfishFileUtils {
	/**
	 * 上传文件
	 * @param path
	 * @param fileName
	 * @param multipartFile
	 * @throws IllegalStateException
	 * @throws IOException
	 */
	public static void uploadFile(String path,String fileName,MultipartFile multipartFile) throws IllegalStateException, IOException{
		//文件名
		File newFile = new File(path,fileName);
		if(!newFile.exists()){
			newFile.mkdirs();
		}
		//传输文件
		multipartFile.transferTo(newFile);
	}
	/**
	 * 删除文件
	 * @param path
	 * @param fileName
	 */
	public static void deleteFile(String path,String fileName){
		File file = new File(path, fileName);
		if(file.exists()){
			file.delete();
		}
	}
	
}
