title: Failure: org.junit.ComparisonFailure: File testfile_1.txt Line 1
body: <p>Its me again...with the same context. I ran a test file in Dr.Java for my constructor. It is about reading a file in the directory to test. Here is part of content in test file:</p>
  
  <pre><code>public void cw_println_file1 () throws Exception {
  String actual, msg, expect;
  String filename;
  CensoredWriter out;
  for(int i=0; i&lt;fileLines.length; i++){
    String [][] test = fileLines[i];
    String censor = test[0][0];
    String [] outLines = test[1];
    String [] expectLines = test[2];
    filename = String.format("testfile_%d.txt",i);
    out = new CensoredWriter(filename,censor);
    for(int j=0; j&lt;outLines.length; j++) { 
    out.println(outLines[j]);
    }
    out.close();
    assertLines(expectLines, filename);
  }
  }
  </code></pre>
  
  <p>I got an error message like this:</p>
  
  <p>File: C:\Users\jiangbuyun\Desktop\lab5\distrib-lab05\Lab05Tests.java  [line: 137]</p>
  
  <p><strong>Failure:</strong> org.junit.ComparisonFailure: File testfile_1.txt Line 1</p>
  
  <p><strong>Expect:</strong> A %!^<em>#@er-scooper, or %!^</em>#@ scoop, is a device used to pick up animal</p>
  
  <p><strong>Actual:</strong> A %!^<em>#@er-scooper, or %!^</em>#@ scoop, is a device used to pick up animalfeces from public places and yards, particularly those ofdogs. %!^*#@er-scooper devices often have a bag or bag attachment.</p>
  
  <p><strong>Expected:</strong>&lt;...ed to pick up animal[]> </p>
  
  <p><strong>but was:</strong>&lt;...ed to pick up animal[feces from public places and yards, particularly those ofdogs. %!^*#@er-scooper devices often have a bag or bag attachment.]</p>
  
  <p>I found it is supposed to stop at the brackets after "animal" and nothing is between the two brackets, but it actually continued to read text and put it into the brackets.</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.replaceAll(censored, "%!^*#@");
      return a;
  }
  
  @Override
  public void print(String s) {
      super.print(transform(s));
  }
  
  @Override
  public void println(String s) {
      print(s);
      flush();
  }
  </code></pre>
  
  <p>}</p>