You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
990 B
Java

package com.docus.bgts.utils;
import com.alibaba.fastjson.JSON;
import com.docus.bgts.enums.Codes;
import java.io.File;
import java.io.IOException;
import java.util.Map;
public class FileUtils {
/**
* 获取jar包所在位置
*
* @return
*/
public static String currentPath() {
File dir = new File(".");
String currentpath = "";
try {
currentpath = dir.getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
return currentpath;
}
/**
* 获取静态文件中的内容
* @param name
* @return
*/
public static Object getJsonByName(String name){
//获取目录结构
String path = FileUtils.currentPath();
//解析json映射文件
String json = JsonUtils.readJsonFile(path + Codes.JSON_ADDRESS.getMessage());
Map jsonMap = JSON.parseObject(json, Map.class);
return jsonMap.get(name);
}
}