Class FileMatchers

java.lang.Object
org.hamcrest.io.FileMatchers

public final class FileMatchers extends Object
Matchers for properties of files.
  • Field Details

  • Method Details

    • anExistingDirectory

      public static Matcher<File> anExistingDirectory()
      A matcher that checks if a directory exists.
      Returns:
      the file matcher
    • anExistingFileOrDirectory

      public static Matcher<File> anExistingFileOrDirectory()
      A matcher that checks if a file or directory exists.
      Returns:
      the file matcher
    • anExistingFile

      public static Matcher<File> anExistingFile()
      A matcher that checks if a file exists.
      Returns:
      the file matcher
    • aReadableFile

      public static Matcher<File> aReadableFile()
      A matcher that checks if a file is readable.
      Returns:
      the file matcher
    • aWritableFile

      public static Matcher<File> aWritableFile()
      A matcher that checks if a directory is writable.
      Returns:
      the file matcher
    • aFileWithSize

      public static Matcher<File> aFileWithSize(long size)
      A matcher that checks if a file has a specific size.
      Parameters:
      size - the expected size
      Returns:
      the file matcher
    • aFileWithSize

      public static Matcher<File> aFileWithSize(Matcher<Long> expected)
      A matcher that checks if a file size matches an expected size.
      Parameters:
      expected - matcher for the expected size
      Returns:
      the file matcher
    • aFileNamed

      public static Matcher<File> aFileNamed(Matcher<String> expected)
      A matcher that checks if a file name matches an expected name.
      Parameters:
      expected - the expected name
      Returns:
      the file matcher
    • aFileWithCanonicalPath

      public static Matcher<File> aFileWithCanonicalPath(Matcher<String> expected)
      A matcher that checks if a file canonical path matches an expected path.
      Parameters:
      expected - the expected path
      Returns:
      the file matcher
    • aFileWithAbsolutePath

      public static Matcher<File> aFileWithAbsolutePath(Matcher<String> expected)
      A matcher that checks if a file absolute path matches an expected path.
      Parameters:
      expected - the expected path
      Returns:
      the file matcher