選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

OutputComparator.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. package common;
  2. import java.io.*;
  3. import java.util.Vector;
  4. public class OutputComparator
  5. {
  6. /**
  7. * Ignores lines that contain "Generated by javadoc on".
  8. *
  9. * @return the lines that don't match in the two files as a Vector of Strings,
  10. * or null if they are the same.
  11. */
  12. public Vector compareFilesByLine(String file1, String file2) throws IOException {
  13. Vector diffLines = new Vector();
  14. BufferedReader reader1 = new BufferedReader(new FileReader(file1));
  15. BufferedReader reader2 = new BufferedReader(new FileReader(file2));
  16. String line1 = reader1.readLine();
  17. String line2 = reader2.readLine();
  18. while (line1 != null && line2 != null) {
  19. if (!line1.trim().equals(line2.trim()) &&
  20. line1.indexOf("Generated by javadoc on") == -1 ) {
  21. diffLines.addElement(line1 + " != " + line2);
  22. }
  23. line1 = reader1.readLine();
  24. line2 = reader2.readLine();
  25. }
  26. if (diffLines.size() == 0) {
  27. return null;
  28. }
  29. else {
  30. return diffLines;
  31. }
  32. }
  33. }