public static void main( String[] argv ) {
	
	try {
	    String[] stopMarks = new String[] {
		"%MARK_0%",
		"%MARK_A%",
		"%MARK_B%",
		"%MARK_C%",
		"%MARK_D%"
	    };
	    String[] replacements = new String[] {
		"Hello",
		"This",
		"very",
		"stream replacement",
		"Goodbye."
	    };
	    String data = 
		stopMarks[0] +
		" World. " + 
		stopMarks[1] + 
		" is a " + 
		stopMarks[2] + 
		" simple " + 
		stopMarks[3] + 
		" test. " +
		stopMarks[4];
	    System.out.println( "data: " + data );


	    Map<byte[],byte[]> replacementMap = new java.util.TreeMap<byte[],byte[]>( new ByteArrayComparator() );
	    System.out.print( "Replacement map: { " );
	    for( int i = 0; i < stopMarks.length; i++ ) {
		replacementMap.put( stopMarks[i].getBytes(java.nio.charset.StandardCharsets.UTF_8.name()), 
				    replacements[i].getBytes(java.nio.charset.StandardCharsets.UTF_8.name())
				    );

		if( i > 0 )
		    System.out.print( ", " );
		System.out.print( "(" + stopMarks[i] + "," + replacements[i] + ")" );
	    }
	    System.out.println( " }" );

	    
	    ReplacingInputStream in = 
		new ReplacingInputStream( new java.io.ByteArrayInputStream(data.getBytes(java.nio.charset.StandardCharsets.UTF_8.name())),
					  replacementMap );

	    int b;
	    while( (b = in.read()) != -1 ) {
		System.out.print( (char)b );
	    }
	    System.out.println( "" );

	    in.close();
	    

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

    }