Class AbstractFileAssert<SELF extends AbstractFileAssert<SELF>>
- Type Parameters:
SELF
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" for more details.
- All Implemented Interfaces:
Assert<SELF,
,File> Descriptable<SELF>
,ExtensionPoints<SELF,
File>
- Direct Known Subclasses:
FileAssert
File
s.- Author:
- David DIDIER, Yvonne Wang, Alex Ruiz, Olivier Michallat, Olivier Demeijer, Mikhail Mazursky, Jean-Christophe Gay, Valeriy Vyrva, Nikolaos Georgiou
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturnsByteArray
assertions on the content of the actualFile
read.canRead()
Verifies that the actualFile
can be read by the application.canWrite()
Verifies that the actualFile
can be modified by the application.content()
Returns String assertions on the content of the actualFile
read with thedefault charset
.Returns String assertions on the content of the actualFile
read with the givenCharset
.Verifies that the actualFile
does not exist.exists()
Verifies that the actualFile
exists, regardless it's a file or directory.hasBinaryContent
(byte[] expected) Verifies that the binary content of the actualFile
is exactly equal to the given one.hasContent
(String expected) Verifies that the text content of the actualFile
is exactly equal to the given one.
The charset to use when reading the file should be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used.hasContentEqualTo
(File expected) Deprecated.Verifies that the testedFile
digest (calculated with the specified algorithm) is equal to the given one.Verifies that the testedFile
digest (calculated with the specified algorithm) is equal to the given one.hasDigest
(MessageDigest digest, byte[] expected) Verifies that the testedFile
digest (calculated with the specifiedMessageDigest
) is equal to the given one.hasDigest
(MessageDigest digest, String expected) Verifies that the testedFile
digest (calculated with the specifiedMessageDigest
) is equal to the given one.hasExtension
(String expected) Verifies that the actualFile
has given extension.hasFileName
(String expected) Verifies that the actualFile
has given name (alias ofhasName(String)
).Verifies that the actualFile
has given name.Verifies that the actualFile
has no extension.Verifies that the actualFile
does not have a parent.Verifies that the actualFile
has given parent.hasSameBinaryContentAs
(File expected) Verifies that the content of the actualFile
is equal to the content of the given one, the comparison is done at the binary level.
For text files, usehasSameTextualContentAs(File)
.hasSameContentAs
(File expected) Deprecated.usehasSameTextualContentAs(File)
instead.hasSameContentAs
(File expected, Charset expectedCharset) Deprecated.usehasSameTextualContentAs(File, Charset)
insteadhasSameTextualContentAs
(File expected) Verifies that the content of the actualFile
is equal to the content of the given one.hasSameTextualContentAs
(File expected, Charset expectedCharset) Verifies that the content of the actualFile
is the same as the expected one, the expectedFile
being read with the given charset while the charset used to read the actual path can be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used.hasSize
(long expectedSizeInBytes) Verifies that the size of theFile
under test is exactly equal to the given size in bytes.Verifies that the actualFile
is an absolute path.Verifies that the actualFile
is an existing directory.isDirectoryContaining
(String syntaxAndPattern) Verify that the actualFile
is a directory containing at least one file matching the givenString
interpreted as a path matcher (as perFileSystem.getPathMatcher(String)
).isDirectoryContaining
(Predicate<File> filter) Verify that the actualFile
is a directory containing at least one file matching the givenPredicate<File>
.isDirectoryNotContaining
(String syntaxAndPattern) Verify that the actualFile
is a directory that does not contain any files matching the givenString
interpreted as a path matcher (as perFileSystem.getPathMatcher(String)
).isDirectoryNotContaining
(Predicate<File> filter) Verify that the actualFile
is a directory that does not contain any files matching the givenPredicate<File>
.isDirectoryRecursivelyContaining
(String syntaxAndPattern) Verify that the actualFile
directory or any of its subdirectories (recursively) contains at least one file matching the givenString
interpreted as a path matcher (as perFileSystem.getPathMatcher(String)
).Verify that the actualFile
directory or any of its subdirectories (recursively) contains at least one file matching the givenPredicate<File>
.isEmpty()
Verify that the actualFile
is empty (i.e.Verify that the actualFile
is an empty directory.isFile()
Verifies that the actualFile
is an existing file.Verify that the actualFile
is not empty (i.e.Verify that the actualFile
is a non empty directory.Verifies that the actualFile
can be read by the application (alias ofcanRead()
)Verifies that the actualFile
is a relative path.Verifies that the actualFile
can be modified by the application (alias ofcanWrite()
.size()
Returns anAssert
object that allows performing assertions on the size of theFile
under test.usingCharset
(String charsetName) Specifies the name of the charset to use for text-based assertions on the file's contents.usingCharset
(Charset charset) Specifies the charset to use for text-based assertions on the file's contents.Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs
-
Constructor Details
-
AbstractFileAssert
-
-
Method Details
-
exists
Verifies that the actualFile
exists, regardless it's a file or directory.Example:
File tmpFile = File.createTempFile("tmp", "txt"); File tmpDir = Files.createTempDirectory("tmpDir").toFile(); // assertions will pass assertThat(tmpFile).exists(); assertThat(tmpDir).exists(); tmpFile.delete(); tmpDir.delete(); // assertions will fail assertThat(tmpFile).exists(); assertThat(tmpDir).exists();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.
-
doesNotExist
Verifies that the actualFile
does not exist.Example:
File parentDir = Files.createTempDirectory("tmpDir").toFile(); File tmpDir = new File(parentDir, "subDir"); File tmpFile = new File(parentDir, "a.txt"); // assertions will pass assertThat(tmpDir).doesNotExist(); assertThat(tmpFile).doesNotExist(); tmpDir.mkdir(); tmpFile.createNewFile(); // assertions will fail assertThat(tmpFile).doesNotExist(); assertThat(tmpDir).doesNotExist();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
exists.
-
isFile
Verifies that the actualFile
is an existing file.Example:
File tmpFile = File.createTempFile("tmp", "txt"); // assertion will pass assertThat(tmpFile).isFile(); tmpFile.delete(); File tmpDir = Files.createTempDirectory("tmpDir").toFile(); // assertions will fail assertThat(tmpFile).isFile(); assertThat(tmpDir).isFile();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.
-
isDirectory
Verifies that the actualFile
is an existing directory.Example:
File tmpDir = Files.createTempDirectory("tmpDir").toFile(); // assertion will pass assertThat(tmpDir).isDirectory(); tmpDir.delete(); File tmpFile = File.createTempFile("tmp", "txt"); // assertions will fail assertThat(tmpFile).isDirectory(); assertThat(tmpDir).isDirectory();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.
-
isAbsolute
Verifies that the actualFile
is an absolute path.Example:
File absoluteFile = File.createTempFile("tmp", "txt"); // assertions will pass assertThat(absoluteFile).isAbsolute(); File relativeFile = new File("./test"); // assertion will fail assertThat(relativeFile).isAbsolute();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an absolute path.
-
isRelative
Verifies that the actualFile
is a relative path.Example:
File relativeFile = new File("./test"); // assertion will pass assertThat(relativeFile).isRelative(); File absoluteFile = File.createTempFile("tmp", "txt"); // assertion will fail assertThat(absoluteFile).isRelative();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not a relative path.
-
isReadable
Verifies that the actualFile
can be read by the application (alias ofcanRead()
)Example:
File tmpFile = File.createTempFile("tmp", "txt"); File tmpDir = Files.createTempDirectory("tmp").toFile(); // assertions will pass assertThat(tmpFile).isReadable(); assertThat(tmpDir).isReadable(); tmpFile.setReadable(false); tmpDir.setReadable(false); // assertions will fail assertThat(tmpFile).isReadable(); assertThat(tmpDir).isReadable();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
can not be read by the application.- Since:
- 3.21.0
- See Also:
-
hasContentEqualTo
Deprecated.usehasSameTextualContentAs(File)
insteadVerifies that the content of the actualFile
is equal to the content of the given one. The charset to use when reading the actual file can be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used. Examples:// use the default charset File xFile = Files.write(Paths.get("xfile.txt"), "The Truth Is Out There".getBytes()).toFile(); File xFileClone = Files.write(Paths.get("xfile-clone.txt"), "The Truth Is Out There".getBytes()).toFile(); File xFileFrench = Files.write(Paths.get("xfile-french.txt"), "La Vérité Est Ailleurs".getBytes()).toFile(); // use UTF-8 charset File xFileUTF8 = Files.write(Paths.get("xfile-clone.txt"), Arrays.asList("The Truth Is Out There"), StandardCharsets.UTF_8).toFile(); // The following assertion succeeds (default charset is used): assertThat(xFile).hasSameContentAs(xFileClone); // The following assertion succeeds (UTF-8 charset is used to read xFile): assertThat(xFileUTF8).usingCharset("UTF-8").hasContent(xFileClone); // The following assertion fails: assertThat(xFile).hasSameContentAs(xFileFrench);
- Parameters:
expected
- the givenFile
to compare the actualFile
to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenFile
isnull
.IllegalArgumentException
- if the givenFile
is not an existing file.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the content of the given one.
-
hasSameContentAs
Deprecated.usehasSameTextualContentAs(File)
instead.Verifies that the content of the actual
File
is equal to the content of the given one. The charset to use when reading the actual file can be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used. Examples:// use the default charset File xFile = Files.write(Paths.get("xfile.txt"), "The Truth Is Out There".getBytes()).toFile(); File xFileClone = Files.write(Paths.get("xfile-clone.txt"), "The Truth Is Out There".getBytes()).toFile(); File xFileFrench = Files.write(Paths.get("xfile-french.txt"), "La Vérité Est Ailleurs".getBytes()).toFile(); // use UTF-8 charset File xFileUTF8 = Files.write(Paths.get("xfile-clone.txt"), Arrays.asList("The Truth Is Out There"), StandardCharsets.UTF_8).toFile(); // The following assertion succeeds (default charset is used): assertThat(xFile).hasSameContentAs(xFileClone); // The following assertion succeeds (UTF-8 charset is used to read xFile): assertThat(xFileUTF8).usingCharset("UTF-8").hasSameContentAs(xFileClone); // The following assertion fails: assertThat(xFile).hasSameContentAs(xFileFrench);
- Parameters:
expected
- the givenFile
to compare the actualFile
to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenFile
isnull
.IllegalArgumentException
- if the givenFile
is not an existing file.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the content of the given one.
-
hasSameTextualContentAs
Verifies that the content of the actualFile
is equal to the content of the given one. The charset to use when reading the actual file can be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used. Examples:// use the default charset File xFile = Files.write(Paths.get("xfile.txt"), "The Truth Is Out There".getBytes()).toFile(); File xFileClone = Files.write(Paths.get("xfile-clone.txt"), "The Truth Is Out There".getBytes()).toFile(); File xFileFrench = Files.write(Paths.get("xfile-french.txt"), "La Vérité Est Ailleurs".getBytes()).toFile(); // use UTF-8 charset File xFileUTF8 = Files.write(Paths.get("xfile-clone.txt"), Arrays.asList("The Truth Is Out There"), StandardCharsets.UTF_8).toFile(); // The following assertion succeeds (default charset is used): assertThat(xFile).hasSameTextualContentAs(xFileClone); // The following assertion succeeds (UTF-8 charset is used to read xFile): assertThat(xFileUTF8).usingCharset("UTF-8").hasSameTextualContentAs(xFileClone); // The following assertion fails: assertThat(xFile).hasSameTextualContentAs(xFileFrench);
- Parameters:
expected
- the givenFile
to compare the actualFile
to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenFile
isnull
.IllegalArgumentException
- if the givenFile
is not an existing file.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the content of the given one.- Since:
- 3.15
-
hasSameBinaryContentAs
Verifies that the content of the actualFile
is equal to the content of the given one, the comparison is done at the binary level.
For text files, usehasSameTextualContentAs(File)
.Examples:
// The first two files have the same contents, the third does not File aFile = Files.write(Paths.get("a-file.bin"), new byte[] { 42 }).toFile(); File bFile = Files.write(Paths.get("b-file.bin"), new byte[] { 42 }).toFile(); File cFile = Files.write(Paths.get("c-file.bin"), new byte[] { 24 }).toFile(); // The following assertion succeeds: assertThat(aFile).hasSameBinaryContentAs(bFile); // The following assertion fails: assertThat(aFile).hasSameBinaryContent(cFile);
- Parameters:
expected
- the givenFile
to compare the actualFile
to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenFile
isnull
.IllegalArgumentException
- if the givenFile
is not an existing file.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the content of the given one.- Since:
- 3.15
-
hasSameContentAs
Deprecated.usehasSameTextualContentAs(File, Charset)
insteadVerifies that the content of the actualFile
is the same as the expected one, the expectedFile
being read with the given charset while the charset used to read the actual path can be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used.Examples:
File fileUTF8 = Files.write(Paths.get("actual"), Collections.singleton("Gerçek"), StandardCharsets.UTF_8).toFile(); Charset turkishCharset = Charset.forName("windows-1254"); File fileTurkishCharset = Files.write(Paths.get("expected"), Collections.singleton("Gerçek"), turkishCharset).toFile(); // The following assertion succeeds: assertThat(fileUTF8).usingCharset(StandardCharsets.UTF_8).hasSameContentAs(fileTurkishCharset, turkishCharset); // The following assertion fails: assertThat(fileUTF8).usingCharset(StandardCharsets.UTF_8).hasSameContentAs(fileTurkishCharset, StandardCharsets.UTF_8);
- Parameters:
expected
- the givenFile
to compare the actualFile
to.expectedCharset
- theCharset
used to read the content of the expected file.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenFile
isnull
.IllegalArgumentException
- if the givenFile
is not an existing file.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the content of the given one.
-
hasSameTextualContentAs
Verifies that the content of the actualFile
is the same as the expected one, the expectedFile
being read with the given charset while the charset used to read the actual path can be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used.Examples:
File fileUTF8 = Files.write(Paths.get("actual"), Collections.singleton("Gerçek"), StandardCharsets.UTF_8).toFile(); Charset turkishCharset = Charset.forName("windows-1254"); File fileTurkishCharset = Files.write(Paths.get("expected"), Collections.singleton("Gerçek"), turkishCharset).toFile(); // The following assertion succeeds: assertThat(fileUTF8).usingCharset(StandardCharsets.UTF_8).hasSameTextualContentAs(fileTurkishCharset, turkishCharset); // The following assertion fails: assertThat(fileUTF8).usingCharset(StandardCharsets.UTF_8).hasSameTextualContentAs(fileTurkishCharset, StandardCharsets.UTF_8);
- Parameters:
expected
- the givenFile
to compare the actualFile
to.expectedCharset
- theCharset
used to read the content of the expected file.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenFile
isnull
.IllegalArgumentException
- if the givenFile
is not an existing file.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the content of the given one.- Since:
- 3.13
-
hasBinaryContent
Verifies that the binary content of the actualFile
is exactly equal to the given one.Example:
File bin = File.createTempFile("tmp", "bin"); Files.write(bin.toPath(), new byte[] {1, 1}); // assertion will pass assertThat(bin).hasBinaryContent(new byte[] {1, 1}); // assertion will fail assertThat(bin).hasBinaryContent(new byte[] { }); assertThat(bin).hasBinaryContent(new byte[] {0, 0});
- Parameters:
expected
- the expected binary content to compare the actualFile
's content to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given content isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the given binary content.
-
hasSize
Verifies that the size of theFile
under test is exactly equal to the given size in bytes.Example:
File file = File.createTempFile("tmp", "bin"); Files.write(file.toPath(), new byte[] {1, 1}); // assertion will pass assertThat(file).hasSize(2); // assertions will fail assertThat(file).hasSize(1);
- Parameters:
expectedSizeInBytes
- the expectedFile
's size in bytes.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.AssertionError
- if the size of the actualFile
is not equal to the given size.- Since:
- 3.14.0
-
usingCharset
Specifies the name of the charset to use for text-based assertions on the file's contents.- Parameters:
charsetName
- the name of the charset to use.- Returns:
this
assertion object.- Throws:
IllegalArgumentException
- if the given encoding is not supported on this platform.
-
usingCharset
Specifies the charset to use for text-based assertions on the file's contents.- Parameters:
charset
- the charset to use.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given charset isnull
.
-
hasContent
Verifies that the text content of the actualFile
is exactly equal to the given one.
The charset to use when reading the file should be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used.Example:
// use the default charset File xFile = Files.write(Paths.get("xfile.txt"), "The Truth Is Out There".getBytes()).toFile(); // The following assertion succeeds (default charset is used): assertThat(xFile).hasContent("The Truth Is Out There"); // The following assertion fails: assertThat(xFile).hasContent("La Vérité Est Ailleurs"); // using a specific charset Charset turkishCharset = Charset.forName("windows-1254"); File xFileTurkish = Files.write(Paths.get("xfile.turk"), Collections.singleton("Gerçek"), turkishCharset).toFile(); // The following assertion succeeds: assertThat(xFileTurkish).usingCharset(turkishCharset).hasContent("Gerçek"); // The following assertion fails : assertThat(xFileTurkish).usingCharset(StandardCharsets.UTF_8).hasContent("Gerçek");
- Parameters:
expected
- the expected text content to compare the actualFile
's content to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given content isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the given content.
-
canWrite
Verifies that the actualFile
can be modified by the application.Example:
File tmpFile = File.createTempFile("tmp", "txt"); File tmpDir = Files.createTempDirectory("tmp").toFile(); // assertions will pass assertThat(tmpFile).canWrite(); assertThat(tmpDir).canWrite(); tmpFile.setReadOnly(); tmpDir.setReadOnly(); // assertions will fail assertThat(tmpFile).canWrite(); assertThat(tmpDir).canWrite();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
can not be modified by the application.- See Also:
-
isWritable
Verifies that the actualFile
can be modified by the application (alias ofcanWrite()
.Example:
File tmpFile = File.createTempFile("tmp", "txt"); File tmpDir = Files.createTempDirectory("tmp").toFile(); // assertions will pass assertThat(tmpFile).isWritable(); assertThat(tmpDir).isWritable(); tmpFile.setReadOnly(); tmpDir.setReadOnly(); // assertions will fail assertThat(tmpFile).isWritable(); assertThat(tmpDir).isWritable();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
can not be modified by the application.- Since:
- 3.21.0
- See Also:
-
canRead
Verifies that the actualFile
can be read by the application.Example:
File tmpFile = File.createTempFile("tmp", "txt"); File tmpDir = Files.createTempDirectory("tmp").toFile(); // assertions will pass assertThat(tmpFile).canRead(); assertThat(tmpDir).canRead(); tmpFile.setReadable(false); tmpDir.setReadable(false); // assertions will fail assertThat(tmpFile).canRead(); assertThat(tmpDir).canRead();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
can not be read by the application.
-
hasParent
Verifies that the actualFile
has given parent.Example:
File xFile = new File("mulder/xFile"); // assertion will pass assertThat(xFile).hasParent(new File("mulder")); // assertion will fail assertThat(xFile).hasParent(new File("scully"));
- Parameters:
expected
- the expected parentFile
.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the expected parentFile
isnull
.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
parent is not equal to the expected one.- See Also:
-
hasParent
Same ashasParent(java.io.File)
but takes care of converting givenString
asFile
for youExample:
File xFile = new File("mulder/xFile"); // assertion will pass assertThat(xFile).hasParent("mulder"); // assertion will fail assertThat(xFile).hasParent("scully");
- Parameters:
expected
- the expected parent file path.- Returns:
this
assertion object.
-
hasExtension
Verifies that the actualFile
has given extension.Example:
File xFile = new File("xFile.java"); // assertion will pass assertThat(xFile).hasExtension("java"); // assertion will fail assertThat(xFile).hasExtension("png");
- Parameters:
expected
- the expected extension, it does not contains the'.'
- Returns:
this
assertion object.- Throws:
NullPointerException
- if the expected extension isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not a file (ie a directory).AssertionError
- if the actualFile
does not have the expected extension.- See Also:
-
hasName
Verifies that the actualFile
has given name.Example:
File xFile = new File("somewhere/xFile.java"); File xDirectory = new File("somewhere/xDirectory"); // assertion will pass assertThat(xFile).hasName("xFile.java"); assertThat(xDirectory).hasName("xDirectory"); // assertion will fail assertThat(xFile).hasName("xFile"); assertThat(xDirectory).hasName("somewhere");
- Parameters:
expected
- the expectedFile
name.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the expected name isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not have the expected name.- See Also:
-
hasFileName
Verifies that the actualFile
has given name (alias ofhasName(String)
).Example:
File xFile = new File("somewhere/xFile.java"); File xDirectory = new File("somewhere/xDirectory"); // assertion will pass assertThat(xFile).hasFileName("xFile.java"); assertThat(xDirectory).hasFileName("xDirectory"); // assertion will fail assertThat(xFile).hasFileName("xFile"); assertThat(xDirectory).hasFileName("somewhere");
- Parameters:
expected
- the expectedFile
name.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the expected name isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not have the expected name.- Since:
- 3.21.0
- See Also:
-
hasNoParent
Verifies that the actualFile
does not have a parent.Example:
File xFile = new File("somewhere/xFile.java"); File xDirectory = new File("xDirectory"); // assertion will pass assertThat(xDirectory).hasNoParent(); // assertion will fail assertThat(xFile).hasNoParent();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
has a parent.
-
hasDigest
Verifies that the testedFile
digest (calculated with the specifiedMessageDigest
) is equal to the given one.Note that the
File
must be readable.Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar File tested = new File("assertj-core-2.9.0.jar"); // The following assertions succeed: assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), new byte[]{92, 90, -28, 91, 88, -15, 32, 35, -127, 122, -66, 73, 36, 71, -51, -57, -111, 44, 26, 44}); assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), new byte[]{-36, -77, 1, 92, -46, -124, 71, 100, 76, -127, 10, -13, 82, -125, 44, 25}); // The following assertions fail: assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad".getBytes()); assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), "3735dff8e1f9df0492a34ef075205b8f".getBytes());
- Parameters:
digest
- the MessageDigest used to calculate the digests.expected
- the expected binary content to compare the actualFile
's content to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given algorithm isnull
.NullPointerException
- if the given digest isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.AssertionError
- if the actualFile
is not an file.AssertionError
- if the actualFile
is not readable.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the testedFile
's digest is not equal to the given one.- Since:
- 3.11.0
-
hasDigest
Verifies that the testedFile
digest (calculated with the specifiedMessageDigest
) is equal to the given one.Note that the
File
must be readable.Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar File tested = new File("assertj-core-2.9.0.jar"); // The following assertions succeed: assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), "5c5ae45b58f12023817abe492447cdc7912c1a2c"); assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), "dcb3015cd28447644c810af352832c19"); // The following assertions fail: assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad"); assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), "3735dff8e1f9df0492a34ef075205b8f");
- Parameters:
digest
- the MessageDigest used to calculate the digests.expected
- the expected binary content to compare the actualFile
's content to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given algorithm isnull
.NullPointerException
- if the given digest isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.AssertionError
- if the actualFile
is not an file.AssertionError
- if the actualFile
is not readable.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the content of the testedFile
's digest is not equal to the given one.- Since:
- 3.11.0
-
hasDigest
Verifies that the testedFile
digest (calculated with the specified algorithm) is equal to the given one.Note that the
File
must be readable.Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar File tested = new File("assertj-core-2.9.0.jar"); // The following assertions succeed: assertThat(tested).hasDigest("SHA1", new byte[]{92, 90, -28, 91, 88, -15, 32, 35, -127, 122, -66, 73, 36, 71, -51, -57, -111, 44, 26, 44}); assertThat(tested).hasDigest("MD5", new byte[]{-36, -77, 1, 92, -46, -124, 71, 100, 76, -127, 10, -13, 82, -125, 44, 25}); // The following assertions fail: assertThat(tested).hasDigest("SHA1", "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad".getBytes()); assertThat(tested).hasDigest("MD5", "3735dff8e1f9df0492a34ef075205b8f".getBytes());
- Parameters:
algorithm
- the algorithm used to calculate the digests.expected
- the expected digest to compare the actualFile
's digest to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given algorithm isnull
.NullPointerException
- if the given digest isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.AssertionError
- if the actualFile
is not an file.AssertionError
- if the actualFile
is not readable.UncheckedIOException
- if any I/O error occurs.AssertionError
- if the content of the testedFile
's digest is not equal to the given one.- Since:
- 3.11.0
-
hasDigest
Verifies that the testedFile
digest (calculated with the specified algorithm) is equal to the given one.Note that the
File
must be readable.Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar File tested = new File("assertj-core-2.9.0.jar"); // The following assertions succeed: assertThat(tested).hasDigest("SHA1", "5c5ae45b58f12023817abe492447cdc7912c1a2c"); assertThat(tested).hasDigest("MD5", "dcb3015cd28447644c810af352832c19"); // The following assertions fail: assertThat(tested).hasDigest("SHA1", "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad"); assertThat(tested).hasDigest("MD5", "3735dff8e1f9df0492a34ef075205b8f");
- Parameters:
algorithm
- the algorithm used to calculate the digests.expected
- the expected digest to compare the actualFile
's digest to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given algorithm isnull
.NullPointerException
- if the given digest isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.AssertionError
- if the actualFile
is not an file.AssertionError
- if the actualFile
is not readable.UncheckedIOException
- if any I/O error occurs.AssertionError
- if the content of the testedFile
's digest is not equal to the given one.- Since:
- 3.11.0
-
isDirectoryContaining
Verify that the actualFile
is a directory containing at least one file matching the givenPredicate<File>
.Note that the actual
File
must exist and be a directory.Given the following directory structure:
Here are some assertions examples:/root/ /root/sub-dir-1/ /root/sub-dir-1/file-1.ext /root/sub-dir-1/file-2.ext /root/sub-file-1.ext /root/sub-file-2.ext
File root = new File("root"); // The following assertions succeed: assertThat(root).isDirectoryContaining(file -> file.getName().startsWith("sub-dir")) .isDirectoryContaining(file -> file.getName().startsWith("sub-file")) .isDirectoryContaining(file -> file.getName().endsWith(".ext")) .isDirectoryContaining(File::isDirectory); // The following assertions fail: assertThat(root).isDirectoryContaining(file -> file.getName().startsWith("dir")); assertThat(root).isDirectoryContaining(file -> file.getName().endsWith(".bin"));
- Parameters:
filter
- the filter for files located insideactual
's directory.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given filter isnull
.AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual does not contain any files matching the given predicate.- Since:
- 3.13.0
-
isDirectoryContaining
Verify that the actualFile
is a directory containing at least one file matching the givenString
interpreted as a path matcher (as perFileSystem.getPathMatcher(String)
).Note that the actual
File
must exist and be a directory.Given the following directory structure:
Here are some assertions examples:/root/ /root/sub-dir-1/ /root/sub-dir-1/file-1.ext /root/sub-dir-1/file-2.ext /root/sub-file-1.ext /root/sub-file-2.ext
File root = new File("root"); // The following assertions succeed: assertThat(root).isDirectoryContaining("glob:**sub-dir*") .isDirectoryContaining("glob:**sub-file*") .isDirectoryContaining("glob:**.ext") .isDirectoryContaining("regex:.*ext") .isDirectoryContaining("glob:**.{ext,bin"); // The following assertions fail: assertThat(root).isDirectoryContaining("glob:**dir"); assertThat(root).isDirectoryContaining("glob:**.bin"); assertThat(root).isDirectoryContaining("glob:**.{java,class}");
- Parameters:
syntaxAndPattern
- the syntax and pattern forPathMatcher
as described inFileSystem.getPathMatcher(String)
.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given syntaxAndPattern isnull
.AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual does not contain any files matching the given path matcher.- Since:
- 3.13.0
- See Also:
-
isDirectoryRecursivelyContaining
Verify that the actualFile
directory or any of its subdirectories (recursively) contains at least one file matching the givenString
interpreted as a path matcher (as perFileSystem.getPathMatcher(String)
).That methods performs the same assertion as
isDirectoryContaining(String syntaxAndPattern)
but recursively.Note that the actual
File
must exist and be a directory.Examples given the following directory structure:
root |—— foo | |—— foobar | |—— foo-file-1.ext |—— foo-file-2.ext
File root = new File("root"); // The following assertions succeed: assertThat(root).isDirectoryRecursivelyContaining("glob:**foo") .isDirectoryRecursivelyContaining("glob:**ooba*") .isDirectoryRecursivelyContaining("glob:**file-1.ext") .isDirectoryRecursivelyContaining("regex:.*file-2.*") .isDirectoryRecursivelyContaining("glob:**.{ext,dummy}"); // The following assertions fail: assertThat(root).isDirectoryRecursivelyContaining("glob:**fooba"); assertThat(root).isDirectoryRecursivelyContaining("glob:**.bin"); assertThat(root).isDirectoryRecursivelyContaining("glob:**.{java,class}");
- Parameters:
syntaxAndPattern
- the syntax and pattern forPathMatcher
as described inFileSystem.getPathMatcher(String)
.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given syntaxAndPattern isnull
.AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual does not contain recursively any files matching the given path matcher.- Since:
- 3.16.0
- See Also:
-
isDirectoryRecursivelyContaining
Verify that the actualFile
directory or any of its subdirectories (recursively) contains at least one file matching the givenPredicate<File>
.That methods performs the same assertion as
isDirectoryContaining(Predicate filter)
but recursively.Note that the actual
File
must exist and be a directory.Examples given the following directory structure:
Here are some assertions examples:root |—— foo | |—— foobar | |—— foo-file-1.ext |—— foo-file-2.ext
File root = new File("root"); // The following assertions succeed: assertThat(root).isDirectoryRecursivelyContaining(file -> file.getName().startsWith("foo-file-1")) .isDirectoryRecursivelyContaining(file -> file.getName().endsWith("file-2.ext")) .isDirectoryRecursivelyContaining(file -> file.getName().equals("foo")) .isDirectoryRecursivelyContaining(file -> file.getParentFile().getName().equals("foo")) // The following assertions fail: assertThat(root).isDirectoryRecursivelyContaining(file -> file.getName().equals("foo-file-1")) assertThat(root).isDirectoryRecursivelyContaining(file -> file.getName().equals("foo/foobar"));
- Parameters:
filter
- the filter for files located insideactual
's directory.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given filter isnull
.AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual does not contain recursively any files matching the given predicate.- Since:
- 3.16.0
-
isDirectoryNotContaining
Verify that the actualFile
is a directory that does not contain any files matching the givenPredicate<File>
.Note that the actual
File
must exist and be a directory.Given the following directory structure:
Here are some assertions examples:/root/ /root/sub-dir-1/ /root/sub-dir-1/file-1.ext /root/sub-dir-1/file-2.ext /root/sub-file-1.ext /root/sub-file-2.ext
File root = new File("root"); // The following assertions succeed: assertThat(root).isDirectoryNotContaining(file -> file.getName().startsWith("dir")) .isDirectoryNotContaining(file -> file.getName().endsWith(".bin")); // The following assertions fail: assertThat(root).isDirectoryNotContaining(file -> file.getName().startsWith("sub-dir")); assertThat(root).isDirectoryNotContaining(file -> file.getName().startsWith("sub-file")); assertThat(root).isDirectoryNotContaining(file -> file.getName().endsWith(".ext")); assertThat(root).isDirectoryNotContaining(File::isDirectory);
- Parameters:
filter
- the filter for files located insideactual
's directory.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given filter isnull
.AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual contains a file matching the given predicate.- Since:
- 3.13.0
-
isDirectoryNotContaining
Verify that the actualFile
is a directory that does not contain any files matching the givenString
interpreted as a path matcher (as perFileSystem.getPathMatcher(String)
).Note that the actual
File
must exist and be a directory.Given the following directory structure:
Here are some assertions examples:/root/ /root/sub-dir-1/ /root/sub-dir-1/file-1.ext /root/sub-dir-1/file-2.ext /root/sub-file-1.ext /root/sub-file-2.ext
File root = new File("root"); // The following assertions succeed: assertThat(root).isDirectoryNotContaining("glob:**dir") .isDirectoryNotContaining("glob:**.bin") .isDirectoryNotContaining("regex:.*bin") .isDirectoryNotContaining("glob:**.{java,class}"); // The following assertions fail: assertThat(root).isDirectoryNotContaining("glob:**sub-dir*"); assertThat(root).isDirectoryNotContaining("glob:**sub-file*"); assertThat(root).isDirectoryNotContaining("glob:**.ext"); assertThat(root).isDirectoryNotContaining("regex:.*ext"); assertThat(root).isDirectoryNotContaining("glob:**.{ext,bin");
- Parameters:
syntaxAndPattern
- the syntax and pattern forPathMatcher
as described inFileSystem.getPathMatcher(String)
.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given syntaxAndPattern isnull
.AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual contains a file matching the given path matcher.- Since:
- 3.13.0
- See Also:
-
isEmptyDirectory
Verify that the actualFile
is an empty directory.Note that the actual
File
must exist and be a directory.Given the following directory structure:
Here are some assertions examples:/root/ /root/sub-dir-1/ /root/sub-dir-1/file-1.ext /root/sub-dir-1/file-2.ext /root/sub-dir-2/ /root/sub-file-1.ext /root/sub-file-2.ext
File root = new File("root"); // The following assertion succeeds: assertThat(new File(root, "sub-dir-2")).isEmptyDirectory(); // The following assertions fail: assertThat(root).isEmptyDirectory(); assertThat(new File(root, "sub-dir-1")).isEmptyDirectory();
- Returns:
this
assertion object.- Throws:
AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual is not empty.- Since:
- 3.13.0
-
isNotEmptyDirectory
Verify that the actualFile
is a non empty directory.Note that the actual
File
must exist and be a directory.Given the following directory structure:
Here are some assertions examples:/root/ /root/sub-dir-1/ /root/sub-dir-1/file-1.ext /root/sub-dir-1/file-2.ext /root/sub-dir-2/ /root/sub-file-1.ext /root/sub-file-2.ext
File root = new File("root"); // The following assertions succeed: assertThat(root).isNotEmptyDirectory(); assertThat(new File(root, "sub-dir-1")).isNotEmptyDirectory(); // The following assertions fail: assertThat(new File(root, "sub-dir-2")).isNotEmptyDirectory();
- Returns:
this
assertion object.- Throws:
AssertionError
- if actual isnull
.AssertionError
- if actual does not exist.AssertionError
- if actual is not a directory.AssertionError
- if actual is empty.- Since:
- 3.13.0
-
isEmpty
Verify that the actualFile
is empty (i.e. the file size = 0).Example:
File file = File.createTempFile("tmp", "txt"); // assertion will pass assertThat(file).isEmpty(); Files.write(file.toPath(), new byte[]{1, 1}); // assertion will fail assertThat(file).isEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.AssertionError
- if the actualFile
is not empty.- Since:
- 3.14.0
-
isNotEmpty
Verify that the actualFile
is not empty (i.e. the file size > 0).Example:
File file = File.createTempFile("tmp", "txt"); Files.write(file.toPath(), new byte[]{1, 1}); // assertion will pass assertThat(file).isNotEmpty(); file = File.createTempFile("tmp", "txt"); // assertion will fail assertThat(file).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.AssertionError
- if the actualFile
is empty.- Since:
- 3.14.0
-
binaryContent
ReturnsByteArray
assertions on the content of the actualFile
read.Example:
File xFile = Files.write(Paths.get("xfile.txt"), "The Truth Is Out There".getBytes()).toFile(); // assertion succeeds assertThat(xFile).binaryContent().isEqualTo("The Truth Is Out There".getBytes()); // assertion fails: assertThat(xFile).binaryContent().isEqualTo("Elsewhere".getBytes());
- Returns:
- a
AbstractByteArrayAssert
object with the binary content of the file. - Throws:
AssertionError
- if the actualFile
is not readable as perFiles.isReadable(java.nio.file.Path)
.UncheckedIOException
- when failing to read the actualFile
.
-
content
Returns String assertions on the content of the actualFile
read with thedefault charset
.Example:
File xFile = Files.write(Paths.get("xfile.txt"), "The Truth Is Out There".getBytes()).toFile(); // assertion succeeds (default charset is used to read xFile content): assertThat(xFile).content().startsWith("The Truth Is "); // assertion fails: assertThat(xFile).content().contains("Elsewhere");
- Returns:
- a StringAssert object with the content of the actual
File
read with the defaultCharset
. - Throws:
AssertionError
- if the actualFile
is not readable.UncheckedIOException
- when failing to read the actualFile
.- Since:
- 3.21.0
-
content
Returns String assertions on the content of the actualFile
read with the givenCharset
.Example:
File utf8File = Files.write(Paths.get("utf8.txt"), "é à".getBytes()).toFile(); // assertion succeeds: assertThat(utf8File).content(StandardCharsets.UTF_8).endsWith("é à"); // assertion fails: assertThat(utf8File).content(StandardCharsets.UTF_8).contains("e");
- Parameters:
charset
- theCharset
to use to read the actualFile
.- Returns:
- a
StringAssert
object with the content of the actualFile
read with the defaultCharset
. - Throws:
AssertionError
- if the actualFile
is not readable.UncheckedIOException
- when failing to read the actualFile
.- Since:
- 3.21.0
-
hasNoExtension
Verifies that the actualFile
has no extension.Example:
// assertions succeed assertThat(new File("file")).hasNoExtension(); assertThat(new File("file.")).hasNoExtension(); // assertion fails assertThat(new File("file.txt")).hasNoExtension();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not a file (ie a directory or does not exist).AssertionError
- if the actualFile
does have an extension.
-
size
Returns anAssert
object that allows performing assertions on the size of theFile
under test.Once this method is called, the object under test is no longer the
File
but its size, to perform assertions on theFile
, callAbstractFileSizeAssert.returnToFile()
.Example:
File file = File.createTempFile("tmp", "bin"); Files.write(file.toPath(), new byte[] {1, 1}); // assertions succeed assertThat(file).size().isGreaterThan(1L).isLessThan(5L) .returnToFile().hasBinaryContent(new byte[] {1, 1}); // assertions fails assertThat(file).size().isBetween(5L, 10L);
- Returns:
- AbstractFileSizeAssert built with the
File
's size. - Throws:
NullPointerException
- if the givenFile
isnull
.- Since:
- 3.22.0
-
hasSameTextualContentAs(File)
instead