public static void main( String[] argv ) {

	try {
	    String[] stopMarks = new String[] {
		"%MARK_0%",
		"%MARK_A%",
		"%MARK_B%",
		"%MARK_C%"
	    };
	    String data = 
		stopMarks[0] +
		"This " + 
		stopMarks[3] + 
		" is a " + 
		stopMarks[2] + 
		" very simple " + 
		stopMarks[1] + 
		" test.";
	    List<byte[]> stopMarkList = new ArrayList<byte[]>( stopMarks.length );
	    System.out.println( "Stop marks: " );
	    for( int i = 0; i < stopMarks.length; i++ ) {
		System.out.println( " [" + i + "] " + stopMarks[i] );
		stopMarkList.add( stopMarks[i].getBytes(java.nio.charset.StandardCharsets.UTF_8.name()) );
	    }
	    System.out.println( "\n" );
	    System.out.println( " data: " + data );
	    
	     

	    MultiStopMarkInputStream in = 
		new MultiStopMarkInputStream( new java.io.ByteArrayInputStream(data.getBytes(java.nio.charset.StandardCharsets.UTF_8.name())),
					      stopMarkList );
	    
	    int i = 0;
	    while( !in.eoiReached() && i < 10 ) {
		int b = -1;
		while( (b = in.read()) != -1 ) {
		    System.out.print( (char)b );
		}
		System.out.println( "" );
		byte[] reachedStopMark = in.getReachedStopMark();
		System.out.println( "Stop mark " + in.getReachedStopMarkIndex() + " found: " + (reachedStopMark==null?"null":new String(reachedStopMark)) );
		
		in.continueStream();
		i++;
	    }


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

    }