预读Json配置文件
来源:互联网 发布:孙鑫java视频教程下载 编辑:程序博客网 时间:2024/05/21 23:05
1.读取配置文件,将文件内容转化为String
public static String ReadFile(String path){BufferedReader reader = null;String laststr = "";//System.out.println("ClassLoader.getSystemResource() :"+ClassLoader.getSystemResource(""));try{InputStream input = ClassLoader.getSystemClassLoader().getResourceAsStream(path);//FileInputStream fileInputStream = new FileInputStream(path);InputStreamReader inputStreamReader = new InputStreamReader(input, "UTF-8");reader = new BufferedReader(inputStreamReader);String tempString = null;while((tempString = reader.readLine()) != null){laststr += tempString;}reader.close();}catch(IOException e){e.printStackTrace();}finally{if(reader != null){try {reader.close();} catch (IOException e) {e.printStackTrace();}}}return laststr;}
3.转化文件内容(这里将文件内容转化为Json)
public final static JsonArray elves_value_js ;static{String elves_value_str = ReadFile("resource/elves_value.json");elves_value_js = JSONArray.fromObject(elves_value_str);}
阅读全文
0 0
- 预读Json配置文件
- struts2注解json 配置文件json
- json配置文件注释
- JSON格式配置文件
- 解析配置文件config.json
- json 作为配置文件
- json作为配置文件
- Unity读取 JSon配置文件
- cocoJS配置文件:project.json
- js读json配置文件
- compsoer config.json配置文件
- Unity读取 JSon配置文件
- json 配置文件解析 写入
- 配置文件json参照
- 读取Json配置文件问题
- Java fastjson 解析json配置文件
- 微信小程序配置文件 .json详解
- TypeScript的配置文件 tsconfig.json
- Multi-Programming-14 线程中断
- Spring中切点表达式的重用
- faster rcnn 源码解析之anchor_target_layer.py
- Android 常用控件(三)
- 使用yum来实现php5.4完美升级php5.6版本
- 预读Json配置文件
- bootstrap-datepicker插件汉化
- 51Nod 数字1的数量
- ES6学习之路(一) let与const
- Markdown入门教程
- SE01 Unit02 正则表达式 、 Object 、 包装类
- JS 事件捕获与事件冒泡
- 修改maven仓库
- 20170612Mac抓包分析工具之Charles