package com.skr.mdm.util.apk;


import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName:
 * @Package:
 * @ClassName:
 * @Author: Tty
 * @Description:
 * @Date: 2021/1/4 15:13
 * @Version: 1.0
 */

public class ReadApkUtils {



	//  获取文件大小
	public static long getFileSize(File file) throws Exception {
		long size = 0;
		if (file.exists()) {
			FileInputStream fis = null;
			fis = new FileInputStream(file);
			size = fis.available();
			fis.close();
		} else {
			file.createNewFile();
		}
		return size;
	}

	//  删除文件和目录
	public static void clearFiles(String path) {
		File file = new File(path);
		if (file.exists()) {
			deleteFile(file);
		}
	}


	public static void deleteFile(File file) {
		if (file.isDirectory()) {
			File[] files = file.listFiles();
			for (int i = 0; i < files.length; i++) {
				//  判断当前文件是否存在多级 递归删除
				deleteFile(files[i]);
			}
		}
		file.delete();
	}
}
