import java.io.InputStream; import java.io.FilterInputStream; import java.io.IOException; public class CensorInputStream extends FilterInputStream { private int characterToRemove; private int characterToInsert; public CensorInputStream( InputStream s, char toRemove, char toInsert ) { super( s ); characterToRemove = (int) toRemove; characterToInsert = (int) toInsert; } public int read() throws IOException { int nextCharacter = super.read(); if ( nextCharacter == characterToRemove ) nextCharacter = characterToInsert; return nextCharacter; } }