Javabasecommonutiliy

编程

1. Read the file on project

static String jsonFileName = "standard_return_bd.json";

ClassLoader classLoader = getClass().getClassLoader();

File file = new File(classLoader.getResource(jsonFileName).getFile());

String absolutePath = file.getAbsolutePath();

System.out.println(absolutePath);

// --common-io on build.gradle-----------

implementation group: "commons-io", name: "commons-io", version: "2.6"

// read file content

String string = FileUtils.readFileToString(file, Charset.defaultCharset());

apache common-io

2. Fastjson to play with Object&JSON

// build.gradle

implementation ("com.alibaba:fastjson:1.2.47")

// String to Object

ImageResult parsed = JSONObject.parseObject(jsonStr, ImageResult.class);

 

 

 

以上是 Javabasecommonutiliy 的全部内容, 来源链接: utcz.com/z/512671.html

回到顶部