private void pretifyJson ( String pathToJson ) throws ReportException { final String outputPath = pathToJson + ".pretty" ; final File in = new File ( pathToJson ) ; final File out = new File ( outputPath ) ; try ( JsonReader reader = new JsonReader ( new InputStreamReader ( new FileInputStream ( in ) , StandardCharsets . UTF_8 ) ) ; JsonWriter writer = new JsonWriter ( new OutputStreamWriter ( new FileOutputStream ( out ) , StandardCharsets . UTF_8 ) ) ) { prettyPrint ( reader , writer ) ; } catch ( IOException ex ) { LOGGER . debug ( "Malformed JSON?" , ex ) ; throw new ReportException ( "Unable to generate json report" , ex ) ; } if ( out . isFile ( ) && in . isFile ( ) && in . delete ( ) ) { try { org . apache . commons . io . FileUtils . moveFile ( out , in ) ; } catch ( IOException ex ) { LOGGER . error ( "Unable to generate pretty report, caused by: {}" , ex . getMessage ( ) ) ; } } }
Reformats the given JSON file .