获得数据库的数据加入到JSONArray,再将数据填入到File中
来源:互联网 发布:java 日期格式化 星期 编辑:程序博客网 时间:2024/06/06 03:39
将数据库获取的数据转为json ,再加入JSONArray中,用 jsonArray.put(json);
//获取数据库的信息,转为json格式
JSONArray jsonArray = new JSONArray();String jsons = "";JSONObject json = new JSONObject();List<CarImageUser> CarImageUsers = new ArrayList<CarImageUser>();CarImageUser c = new CarImageUser();InterCarSomething ic = new CarSomething();List<Carinfo> cif = ic.GetCatInfo();List<CarImageUser> users = ic.User();for(int i=0;i<cif.size();i++){c.setLocationQ(users.get(i).getLocationQ());c.setLocationZ(users.get(i).getLocationZ());c.setUserName(users.get(i).getUserName());c.setDate(users.get(i).getDate());c.setTime(users.get(i).getTime());c.setCarNoYes(users.get(i).isCarNoYes());c.setCityNoYes(users.get(i).isCityNoYes());c.setImageViewName(users.get(i).getImageViewName());c.setImageViewPath(users.get(i).getImageViewPath());CarImageUsers.add(c);json = new JSONObject(c);jsonArray.put(json);}
//将String写入文件中try
try {String jsonString = jsonArray.toString();System.out.print(FileName);File filejson = new File(Path.Path.FilePath+FileName+".json");if(!filejson.exists()){filejson.createNewFile();}FileWriter filewriter = new FileWriter(filejson.getAbsoluteFile());BufferedWriter bufferWriter = new BufferedWriter(filewriter);bufferWriter.write(jsonString);bufferWriter.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}
阅读全文
0 0
- 获得数据库的数据加入到JSONArray,再将数据填入到File中
- Angular将填入表单的数据渲染到表格
- 将Excel数据导入到数据库中
- 将excel数据导入到数据库中
- c# 将图片的二进制数据插入到数据库中
- 将数据库的数据导出到EXCEL中
- 将数据库的数据导入到excel中
- 将数据库的数据导出到Excel表中
- 如何将数据库的数据导入到csv文件中
- 实现将datetable的数据添加到数据库表中
- 将数据库的数据导出到excel表格中。
- 将数据库中表的数据保存到XML文件中
- 用C#实现动态生成Word文档,在Word文档中插入表格,并将读出的数据填入到表格中
- 将给定的数据动态加入到创建的表格中
- 将excel的数据添加到数据库
- 将Excel文件数据导入数据到SQL数据库中
- python从数据库中获得数据到numpy
- 数据库找到数据填入excel中
- 初次接触嵌入式系统和linux
- Java开发中的23种设计模式详解(转)
- 3. Longest Substring Without Repeating Characters
- Android OpenGL 开发3 - 坐标系以及矩阵变换(转)
- Leetcode611. 计算数组中可构成三角形的个数
- 获得数据库的数据加入到JSONArray,再将数据填入到File中
- HDU 2212-DFS
- 表达式语法分析——递归子程序法
- hibernate复合主键映射
- 吴恩达deeplearning之CNN—人脸识别与风格化转换(2)
- Spring框架
- Jdk自带的动态代理技术
- nyoj306 走迷宫(二分+dfs)
- 树的重心(默认已会定义及存储)