package com.dl.utils;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
public class ReadRootPathUtils {
public static String getRootPath() {
String path = "/usr/dlconfig/path.json";
String read = null;
try {
read = FileUtils.readFileToString(new File(path), "UTF-8");
} catch (IOException e) {
e.printStackTrace();
}
return read;
}
public static void main(String[] args) {
//jsonstr
String rootPath = getRootPath();
//jsonobj
JSONObject jobj = JSON.parseObject(rootPath);
System.out.println(jobj.getString("rootPath"));
}
}
fastjson将jsonstr 转化成json 对象 并获取数据
最新推荐文章于 2024-08-28 09:37:32 发布