public class FileCompare
extends java.lang.Object
| Constructor and Description |
|---|
FileCompare() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
compare(java.io.File file1,
java.io.File file2)
compares two files and return true if the files have the same content.
|
static boolean |
compare(java.io.InputStream in1,
java.io.InputStream in2) |
static boolean |
compare(java.lang.String filename1,
java.io.InputStream in)
compares two files and return true if the files have the same content.
|
static boolean |
compare(java.lang.String filename1,
java.lang.String filename2)
compares two files and return true if the files have the same content.
|
static boolean |
compareStrings(java.lang.String in1,
java.lang.String in2)
Compare 2 strings, ignoring whitespace characters
|
static boolean |
compareStringsWithFilter(java.lang.String s1,
java.lang.String s2,
java.util.regex.Pattern pattern)
Compare 2 strings, showing where they differ in output to system.out, after
doing filtering:
normalize cr nl to nl
normalize
|
static boolean |
compareStringsWithMsg(java.lang.String s1,
java.lang.String s2)
Compare two strings, give message indicating where they miscompare, including
approx 10 chars before and after the first miscompare, for context
|
static boolean |
compareWithFilter(java.lang.String filename1,
java.lang.String filename2,
java.util.regex.Pattern pattern)
Compares two files and returns true, if both have the same content, after
filtering using the supplied Pattern.
|
static boolean |
compareXML(java.lang.String filename1,
java.lang.String filename2)
Compares two XML files and returns true, if both have the same content.
|
static java.lang.String |
file2String(java.io.File file)
Read the contents of a file into a string, using the default platform encoding.
|
static java.lang.String |
reader2String(java.io.Reader reader,
int bufSize)
Read a bufferedReader into a string, using the default platform encoding.
|
public static boolean compare(java.lang.String filename1,
java.lang.String filename2)
throws java.io.IOException
filename1 - filename of the first filefilename2 - filename of the second filejava.io.IOExceptionpublic static boolean compare(java.io.File file1,
java.io.File file2)
throws java.io.IOException
file1 - first filefile2 - second filejava.io.IOExceptionpublic static boolean compare(java.lang.String filename1,
java.io.InputStream in)
throws java.io.IOException
filename1 - filename of the first filein - an input Sreamjava.io.IOExceptionpublic static boolean compare(java.io.InputStream in1,
java.io.InputStream in2)
throws java.io.IOException
java.io.IOExceptionpublic static boolean compareStrings(java.lang.String in1,
java.lang.String in2)
in1 - in2 - public static boolean compareXML(java.lang.String filename1,
java.lang.String filename2)
throws java.io.IOException
filename1 - Filename of the first XML file.filename2 - Filename of the second XML file.java.io.IOExceptionpublic static boolean compareWithFilter(java.lang.String filename1,
java.lang.String filename2,
java.util.regex.Pattern pattern)
throws java.io.IOException
filename1 - Filename of the first XML file.filename2 - Filename of the second XML file.pattern - an instance of Pattern which matches all substrings which should be filtered out of the matchjava.io.IOExceptionpublic static boolean compareStringsWithFilter(java.lang.String s1,
java.lang.String s2,
java.util.regex.Pattern pattern)
s1 - s2 - pattern - public static boolean compareStringsWithMsg(java.lang.String s1,
java.lang.String s2)
s1 - first string to compares2 - second string to comparepublic static java.lang.String file2String(java.io.File file)
throws java.io.IOException
file - The file to be read in.java.io.IOException - Various I/O errors. '
TODO: This is duplicated from org.apache.uima.internal.util.FileUtils in the uimaj-core
package. We can't have a compile dependency on uimaj-core since that introduces a cycle. Not
sure what the best way of handling this is.public static java.lang.String reader2String(java.io.Reader reader,
int bufSize)
throws java.io.IOException
reader - to be read inbufSize - - size of stream, in bytes. Size in chars is <= size in bytes, because
chars take 1 or more bytes to encode.java.io.IOException - Various I/O errors.
TODO: This is duplicated from org.apache.uima.internal.util.FileUtils in the uimaj-core
package. We can't have a compile dependency on uimaj-core since that introduces a cycle. Not
sure what the best way of handling this is.Copyright © 2013. All Rights Reserved.