public static void harToFile ( JsonObject har , String destinationDir , String destinationFile ) { // Prepare HAR destination directory File harDestinationDir = new File ( destinationDir ) ; if ( ! harDestinationDir . exists ( ) ) harDestinationDir . mkdirs ( ) ; // Store HAR to disk PrintWriter harDestinationFileWriter = null ; try { // Prepare Writer harDestinationFileWriter = new PrintWriter ( destinationDir + File . separator + destinationFile ) ; // Store HAR if any, otherwise empty file if ( null != har ) { harDestinationFileWriter . print ( har . toString ( ) ) ; } else { harDestinationFileWriter . print ( "" ) ; } } catch ( FileNotFoundException e ) { throw new BMPCUnableToSaveHarToFileException ( e ) ; } finally { if ( null != harDestinationFileWriter ) { harDestinationFileWriter . flush ( ) ; harDestinationFileWriter . close ( ) ; } } }
Utility to store HAR to file .