Class TextFileDetector
java.lang.Object
me.pauleff.common.handlers.files.TextFileDetector
Classifies files as text or binary using a bounded byte-sample heuristic.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisTextBased(Path path) Determines whether a file appears to be text-based rather than binary.
-
Method Details
-
isTextBased
Determines whether a file appears to be text-based rather than binary.Reads up to 8 KiB from the start of the file and counts bytes outside printable ASCII, Latin-1, and common control characters. Empty files are treated as text.
- Parameters:
path- the path to the file to inspect- Returns:
trueif the file is classified as text-based;falseotherwise- Throws:
IllegalArgumentException- ifpathis not a regular fileIOException- if the file cannot be read
-