当前位置: 首页 > news >正文

网页设计作品特色及亮点seo自动点击排名

网页设计作品特色及亮点,seo自动点击排名,为什么建新闻网站,胶州企业网站建设下面的demo当中 &#xff0c;是将json文件放到了zip包当中。如果不需要&#xff0c;可以拿掉。 1、生成对象JSON文件 public static void crateJson() {try {String orcPath "D:\\doc\\ts_service_orchestration.json";// 对象集合或者对象都可以List<DataPO>…

下面的demo当中 ,是将json文件放到了zip包当中。如果不需要,可以拿掉。

1、生成对象JSON文件

	public static void crateJson() {try {String orcPath = "D:\\doc\\ts_service_orchestration.json";// 对象集合或者对象都可以List<DataPO> dataPOList = new ArrayList<>();String jsonString = JSONObject.toJSONString(dataPOList);// 生成json文件tempFile(orcPath, jsonString);FileInputStream fileInputStream = null;int length;byte[] b = new byte[1024];int len;String path =  "D:\\doc\\压缩包.zip";File zipfile = new File(path);if (!zipfile.exists()) {zipfile.createNewFile();}// 将json文件放入到压缩包当中// key 文件名称, value 文件地址HashMap<String, String> maps = new HashMap<>();maps.put("ts_service_orchestration.json", orcPath);ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));for (Map.Entry<String, String> entry : maps.entrySet()) {File newFile = new File(entry.getValue());fileInputStream = new FileInputStream(newFile);out.putNextEntry(new ZipEntry(entry.getKey()));while ((len = fileInputStream.read(b)) > 0){out.write(b, 0, len);}out.closeEntry();fileInputStream.close();}out.close();// delete jsonFilenew File(orcPath).delete();}catch (Exception e){e.printStackTrace();}}public static void tempFile(String filePath, String jsonData) throws IOException {// 保证创建一个新文件File file = new File(filePath);if (!file.getParentFile().exists()) { // 如果父目录不存在,创建父目录file.getParentFile().mkdirs();}if (file.exists()) { // 如果已存在,删除旧文件file.delete();}file.createNewFile();// 格式化json字符串jsonData = JsonUtil.formatJson(jsonData);// 将格式化后的字符串写入文件Writer write = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");write.write(jsonData);write.flush();write.close();}

2、读取json文件

	public static void readJson(){try {// 转为压缩文件流ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream("D:\\doc\\压缩包.zip"), Charset.forName("gbk"));ZipEntry zipEntry = null;while ((zipEntry = zipInputStream.getNextEntry()) != null) {if (!zipEntry.isDirectory() && zipEntry.getName().endsWith(".json")) {// Read the Excel file from the Zip entryByteArrayOutputStream outputStream = new ByteArrayOutputStream();byte[] buffer = new byte[4096];int length = -1;while ((length = zipInputStream.read(buffer)) != -1) {outputStream.write(buffer, 0, length);}outputStream.close();tempReadFile(outputStream);zipInputStream.closeEntry();}}zipInputStream.close();} catch (IOException e) {e.printStackTrace();}}public static void tempReadFile(ByteArrayOutputStream outputStream) throws IOException {String jsonStr = "";Reader reader = new InputStreamReader(new ByteArrayInputStream(outputStream.toByteArray()),"utf-8");int ch = 0;StringBuffer sb = new StringBuffer();while ((ch = reader.read()) != -1) {sb.append((char) ch);}reader.close();jsonStr = sb.toString();// 这里注意,如果是json文件当中是对象集合的话可以这样写,但是如果是对象的话,这样转换是会出错的。JSONArray array = JSONObject.parseArray(jsonStr);for (Object o : array) {JSONObject jsonObject = (JSONObject)o;System.out.println(jsonObject);}System.out.println("=================================================================");}
http://www.khdw.cn/news/15669.html

相关文章:

  • 爬墙专用加速器河南seo排名
  • 网站搭建南京网站策划是做什么的
  • 企业网站是否可以做淘宝客枫林seo工具
  • 东营网站建设专业定制网络热词的利弊
  • 三亚久爱传媒招聘信息杭州优化seo
  • 网站整套模板项目代码下载武汉网站seo推广
  • 站长之家 网站模板上海优化seo排名
  • 网站扫码充值怎么做的百度网络营销的概念
  • 上海企业登记网络服务平台灰色seo关键词排名
  • 湖南大型网站建设公司视频外链在线生成
  • 动态网站用数据库怎么做重庆百度快照优化
  • iis添加网站 别名百度网站电话是多少
  • 东城网站设计疫情最新动态
  • 网站建设类公司如何推广网址链接
  • 做淘宝团购的网站包头网站建设推广
  • 菏泽企业做网站上海还能推seo吗
  • 厦门网站建设哪家好在线优化工具
  • 合肥建设网站资质办理产品营销策划
  • 个人公司网站建设答辩如何推广网站方法
  • 给窗帘做网站成都广告公司
  • 网站排名易下拉刷词重庆seo优化公司
  • 网站商城是用什么框架做的广告代发平台
  • wordpress 的应用百度首页排名优化平台
  • 网站备案密码使用做网站需要多少钱
  • 哪个网站有介绍拿到家做的手工活seo顾问什么职位
  • 购买网站空间ftp设计广州网站seo推广
  • wordpress生成的html上海关键词优化报价
  • eclipse做的网站网站优化员seo招聘
  • 做网络推广选择网站百度网页pc版登录
  • 做网站怎么加水平线免费发布信息平台有哪些