| |
---|
| | Connection conHsql = DatabaseTool.openDb("database"); |
---|
| | try { |
---|
| | obj.load(conPost, conHsql); |
---|
| | obj.outputCSV(outputFileCsv); |
---|
| | obj.outputJson(outputFileJson); |
---|
| | obj.outputJson(outputFileJson, "Data source"); |
---|
| | } |
---|
| | finally { |
---|
| | DatabaseTool.closeDb(conHsql); |
---|
| | DatabaseTool.closeDb(conPost); |
---|
| |
---|
| | csv.save(); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | public void outputJson(File outputFile) throws FileNotFoundException, UnsupportedEncodingException, IOException { |
---|
| | public void outputJson(File outputFile, String sourcedata) throws FileNotFoundException, UnsupportedEncodingException, IOException { |
---|
| | try (BufferedWriter hw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"))) { |
---|
| | int level = 0; |
---|
| | hw.write(space(level++) + "{"); |
---|
| | hw.newLine(); |
---|
| | hw.write(space(level) + "\"timestamp\": \""+ LocalDate.now().format(DateTimeFormatter.ISO_DATE) +"\","); |
---|
| | hw.newLine(); |
---|
| | hw.write(space(level) + "\"sourcedata\": \"国土数値情報 燃料給油所データ 平成28年(2016)\","); |
---|
| | hw.write(space(level) + "\"sourcedata\": \""+ sourcedata +"\","); |
---|
| | hw.newLine(); |
---|
| | hw.write(space(level++) + "\"coverage\": ["); |
---|
| | hw.newLine(); |
---|
| | boolean head = true; |
---|
| |
---|
| | hw.write(space(level) + "\"name\": \""+ cover.name +"\","); |
---|
| | hw.newLine(); |
---|
| | hw.write(space(level) + "\"denominator\": "+ String.valueOf(cover.denominator) +","); |
---|
| | hw.newLine(); |
---|
| | hw.write(space(level) + "\"molecule\": "+ String.valueOf(cover.molecule) +","); |
---|
| | hw.newLine(); |
---|
| | hw.write(space(level) + "\"par\": "+ String.valueOf(df3.format(cover.par))); |
---|
| | hw.newLine(); |
---|
| | |
---|
| | hw.write(space(--level) + "}"); |
---|
| |
---|
| | |