public static void main( String[] argv ) {

	
	String filename = "document_root/system/errors/GenericError.template.html";
	CustomLogger logger = new ikrs.util.DefaultCustomLogger("test");

	Map<byte[],byte[]> replacementMap = new java.util.TreeMap<byte[],byte[]>( new ikrs.util.ByteArrayComparator() );
	try {

	    replacementMap.put( new String("%{STATUS_CODE}%").getBytes(java.nio.charset.StandardCharsets.UTF_8.name()),
				new String("500").getBytes(java.nio.charset.StandardCharsets.UTF_8.name()) 
				);
	    replacementMap.put( new String("%{REASON_PHRASE}%").getBytes(java.nio.charset.StandardCharsets.UTF_8.name()),
				new String("Iternal Server Error").getBytes(java.nio.charset.StandardCharsets.UTF_8.name()) 
				);
	    replacementMap.put( new String("%{ERROR_MESSAGE}%").getBytes(java.nio.charset.StandardCharsets.UTF_8.name()),
				new String("I encountered an internal server error.").getBytes(java.nio.charset.StandardCharsets.UTF_8.name()) 
				);
	    System.out.println( "Replacement map: " + replacementMap.toString() );

	    
	    System.out.println( "Creating file resource from " + filename );
	    ikrs.httpd.Resource fileResource = new FileResource( null,  // no handler available
									  logger,
									  new java.io.File(filename),
									  false // no need to use fair locks here
									  );
	    System.out.println( "Opening file resource ... ");
	    fileResource.open( true );  // open in read-only mode

	    System.out.println( "Creating replacing resource ... ");
	    ikrs.httpd.Resource replacingResource = new ReplacingResource( null,  
									   logger,
									   fileResource.getInputStream(),
									   false,
									   replacementMap
									   );

	    System.out.println( "Opening replacing resource ..." );
	    replacingResource.open( true );

	    System.out.println( "Reading replacing resource ... ");
	    byte[] buffer = new byte[ 256 ];
	    int len;
	    while( (len = replacingResource.getInputStream().read(buffer)) != -1 ) {

		for( int i = 0; i < len; i++ )
		    System.out.print( (char)buffer[i] );

	    }
	    System.out.println( "" );

	    System.out.println( "Closing replacing resource ... ");
	    replacingResource.close();

	    System.out.println( "Closing file resource ... ");
	    fileResource.close();


	} catch( Exception e ) {
	    e.printStackTrace();
	}


    }