title: CensoredWriter cw = new CensoredWriter(System.out, "whine|whining");
body: <p>I am using Dr.Java to do this constructor. When i typed following in the interactions box</p>
  
  <pre><code>CensoredWriter cw = new CensoredWriter(System.out, "whine|whining");
  
  cw.print("No whining")
  </code></pre>
  
  <p>It returns "No whining", but the right answer should be "No %!^*#@" according to my constructor. What is the problem here?</p>
  
  <pre><code>public class CensoredWriter extends PrintWriter {
  
      String censored;
  
      public CensoredWriter(OutputStream o, String c) {
          super(o);
          this.censored = c;
      }
  
      public CensoredWriter(File f, String c) throws Exception {
          super(f);
          this.censored = c;
      }
  
      public CensoredWriter(String s, String c) throws Exception {
          super(s);
          this.censored = c;
      }
  
      public String transform(String s) {
          String a = s.replace(censored, "%!^*#@");
          return a;
      }
  
      @Override
      public void print(String s) {
          transform(s);
          super.print(s);
          flush();
  
      }
  
      @Override
      public void println(String s) {
          print(s);
          flush();
      }
  }
  </code></pre>