{"id":218,"date":"2025-09-10T11:48:21","date_gmt":"2025-09-10T03:48:21","guid":{"rendered":"https:\/\/www.syh.ac.cn\/?p=218"},"modified":"2025-09-10T11:48:21","modified_gmt":"2025-09-10T03:48:21","slug":"java-scala%e5%a4%a7%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%af%bb%e5%8f%96%e4%b8%8e%e5%86%99%e5%85%a5","status":"publish","type":"post","link":"http:\/\/www.syh.ac.cn\/index.php\/2025\/09\/10\/java-scala%e5%a4%a7%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%af%bb%e5%8f%96%e4%b8%8e%e5%86%99%e5%85%a5\/","title":{"rendered":"java\/scala\u5927\u5b57\u7b26\u4e32\u8bfb\u53d6\u4e0e\u5199\u5165"},"content":{"rendered":"\n<p>\u5927\u6587\u4ef6\u5b57\u7b26\u4e32\u8bfb\u53d6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def readJsonFileToString(filePath: String):String = {\n    val sb = new StringBuilder\n    val buffer = new Array&#91;Char](8192)\n    val reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), \"UTF-8\"))\n    try {\n      var n = 0\n      while ({\n        n = reader.read(buffer)\n        n != -1\n      }) {\n        sb.appendAll(buffer, 0, n)\n      }\n    } finally {\n      reader.close()\n    }\n    sb.toString()\n  }<\/code><\/pre>\n\n\n\n<p>\u5927\u6587\u4ef6\u5199\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    val mapper = new ObjectMapper()\n    val factory = new JsonFactory(mapper)\n    val out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(\"\/zzDatas\/xxx4.json\"), \"UTF-8\"))\n    val jsonGenerator = factory.createGenerator(out)\n    try {\n      mapper.writeValue(jsonGenerator, gisMap)\n    } finally {\n      jsonGenerator.close()\n      out.close()\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u6587\u4ef6\u5b57\u7b26\u4e32\u8bfb\u53d6 \u5927\u6587\u4ef6\u5199\u5165<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,23],"tags":[],"class_list":["post-218","post","type-post","status-publish","format-standard","hentry","category-java","category-23"],"_links":{"self":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts\/218"}],"collection":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":1,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"predecessor-version":[{"id":219,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts\/218\/revisions\/219"}],"wp:attachment":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}