public static void main ( String [ ] args ) throws Exception { if ( args . length < 1 || args . length > 2 ) { throw new IOException ( "One or two arguments expected." ) ; } ServerConfiguration config = new ServerConfigurationParser ( new FileInputStream ( new File ( args [ 0 ] ) ) ) . parse ( ) ; if ( args . length == 2 ) { Properties props = new Properties ( ) ; props . load ( new FileInputStream ( new File ( args [ 1 ] ) ) ) ; config . applyProperties ( props ) ; } ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; config . serialize ( out ) ; String content = new String ( out . toByteArray ( ) , "UTF-8" ) ; System . out . println ( content ) ; }
Deserialize then output the given configuration . If two parameters are given the first one is the filename and the second is the properties file to apply before re - serializing .