public static void main(String[] args)
{
System.out.println("测试开始");
File file = new File("D:/files/req.txt");
BufferedReader reader = null;
String jsonStr = "";
try
{ reader = new BufferedReader(new FileReader(file)); String readLine = "";
while ((readLine = reader.readLine()) != null)
{
jsonStr += readLine + "\n"; } System.out.println(jsonStr);
JSONObject jsonObj;
try
{
jsonObj = new JSONObject(jsonStr);
System.out.println(jsonObj.get("Version"));
System.out.println(jsonObj.get("VimId"));
}
catch (JSONException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} }
catch (FileNotFoundException e)
{
e.printStackTrace();
System.out.println("e" + e.getMessage());
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("error" + e.getMessage());
}
finally
{
if (reader != null)
{
try
{
reader.close();
}
catch (IOException e)
{
System.out.println("close fail!!"+ e.getMessage());
}
}
} }

  输出结果:

测试开始
{
"Version": "1.0",
"VimId": "81f1d9d0-ca13-4eea-a4ce-9bd89a50c9d1",
"SrcType": "vpim",
"MsgType": "vimPmMetrics",
"FileUri": "https://192.168.112.80:9131/v1/vimPm/files/201606011415.gz"
} 1.0
81f1d9d0-ca13-4eea-a4ce-9bd89a50c9d1

  

最新文章

  1. ASP.Net 在Update Panel局部刷新后 重新绑定JS方法
  2. Java多线程21:多线程下的其他组件之CyclicBarrier、Callable、Future和FutureTask
  3. 转:JavaScript中的this陷阱的最全收集
  4. JAVA导入包
  5. Saltstack系列5:Saltstack之pillar组件
  6. Write operations are not allowed in read-only mode (FlushMode.NEVER/
  7. 程序自动生成Dump文件
  8. C# 封装
  9. XP 右键扩展设置 1.0 免费绿色版
  10. xcode7中使用cocos2d-x3.8的webview控件
  11. Java版连连看
  12. 机器学习之正则化(Regularization)
  13. MySql中的约束
  14. tomcat启动失败问题总结
  15. 2018.3 江苏省计算机等级考试 C语言 编程题答案
  16. 安装Linux Mint17
  17. D05——C语言基础学PYTHON
  18. java中JVM的原理
  19. MySQL基础练习(二)
  20. Support for SSL/TLS protocols on Windows

热门文章

  1. firefox浏览器和IE
  2. Android — 长按ListView 利用上下文菜单(ActionMode) 进行批量事件处理
  3. Codeforces Round #422 (Div. 2) B. Crossword solving 枚举
  4. unity 3D Mesh网络模型,怎样将Constructer拖入场景??
  5. Thread Runnable 区别
  6. 使用JavaScript获取浏览器Chrome版本信息
  7. Linux Linker Script
  8. bzoj3090: Coci2009 [podjela]
  9. gunicorn启动django时静态文件的加载
  10. .NETFramework:Encoding