Package com.qulice.spi
Class Binary
java.lang.Object
com.qulice.spi.Binary
A file that is considered binary.
Detects binary files using the classic NULL-byte heuristic: if any
of the first SNIFF bytes of the file is 0x00, the file
is treated as binary. This is the same rule used by git diff
and GNU grep to decide whether a file is text or binary. It
intentionally misclassifies nothing for typical source code (Java, XML,
YAML, JSON, UTF-8) while correctly ignoring images, archives, compiled
classes and similar blobs that should not be fed to text-based
validators such as Checkstyle's RegexpSinglelineCheck.
A file that does not exist, is not a regular file, or is empty is considered non-binary, so the caller may still attempt to open it and fail fast with a clear error, rather than silently skipping it here.
- Since:
- 0.24
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Binary
Ctor.- Parameters:
src- File to inspect
-
-
Method Details
-
yes
public boolean yes()Is the file binary?- Returns:
- TRUE if the first 8192 bytes contain a NULL byte
-