public class FileCompare extends Object
Constructor and Description |
---|
FileCompare() |
Modifier and Type | Method and Description |
---|---|
static boolean |
compare(File file1,
File file2)
compares two files and return true if the files have the same content.
|
static boolean |
compare(InputStream in1,
InputStream in2) |
static boolean |
compare(String filename1,
InputStream in)
compares two files and return true if the files have the same content.
|
static boolean |
compare(String filename1,
String filename2)
compares two files and return true if the files have the same content.
|
static boolean |
compareStrings(String in1,
String in2)
Compare 2 strings, ignoring whitespace characters
|
static boolean |
compareStringsWithFilter(String s1,
String s2,
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(String s1,
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(String filename1,
String filename2,
Pattern pattern)
Compares two files and returns true, if both have the same content, after
filtering using the supplied Pattern.
|
static boolean |
compareXML(String filename1,
String filename2)
Compares two XML files and returns true, if both have the same content.
|
static String |
file2String(File file)
Read the contents of a file into a string, using the default platform encoding.
|
static String |
reader2String(Reader reader,
int bufSize)
Read a bufferedReader into a string, using the default platform encoding.
|
public static boolean compare(String filename1, String filename2) throws IOException
filename1
- filename of the first filefilename2
- filename of the second fileIOException
- -public static boolean compare(File file1, File file2) throws IOException
file1
- first filefile2
- second fileIOException
- -public static boolean compare(String filename1, InputStream in) throws IOException
filename1
- filename of the first filein
- an input SreamIOException
- -public static boolean compare(InputStream in1, InputStream in2) throws IOException
IOException
public static boolean compareStrings(String in1, String in2)
in1
- in2
- public static boolean compareXML(String filename1, String filename2) throws IOException
filename1
- Filename of the first XML file.filename2
- Filename of the second XML file.IOException
- -public static boolean compareWithFilter(String filename1, String filename2, Pattern pattern) throws 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 matchIOException
- -public static boolean compareStringsWithFilter(String s1, String s2, Pattern pattern)
s1
- s2
- pattern
- public static boolean compareStringsWithMsg(String s1, String s2)
s1
- first string to compares2
- second string to comparepublic static String file2String(File file) throws IOException
file
- The file to be read in.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 String reader2String(Reader reader, int bufSize) throws 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.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 © 2006–2015 The Apache Software Foundation. All rights reserved.