public static void serialize ( final File folder , final String content , final String fileName ) throws IOException { if ( ! folder . exists ( ) ) { folder . mkdirs ( ) ; } final File output = new File ( folder , fileName ) ; try ( final FileWriter writer = new FileWriter ( output ) ; ) { writer . write ( content ) ; writer . flush ( ) ; } catch ( Exception e ) { throw new IOException ( "Failed to serialize the notification in folder " + folder . getPath ( ) , e ) ; } }
Serialize a content into a targeted file checking that the parent directory exists .