public class BinaryGuesser extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ASCII_CHAR_THREASHOLD |
static String[] |
BYTECODE_EXTENSIONS |
static String[] |
DATA_EXTENSIONS |
static String[] |
EXE_EXTENSIONS |
static int |
HIGH_BYTES_RATIO |
static String[] |
IMAGE_EXTENSIONS |
static String |
JAR_MANIFEST |
static String |
JAVA |
static String[] |
KEYSTORE_EXTENSIONS |
static int |
NON_ASCII_THREASHOLD |
static String[] |
NON_BINARY_EXTENSIONS
Based on http://www.apache.org/dev/svn-eol-style.txt
|
static int |
TOTAL_READ_RATIO |
Constructor and Description |
---|
BinaryGuesser() |
Modifier and Type | Method and Description |
---|---|
static boolean |
containsExtension(String name,
String[] exts) |
static boolean |
extensionMatches(String name,
String[] exts) |
static boolean |
isBinary(Document document) |
static boolean |
isBinary(InputStream in)
Do the first few bytes of the stream hint at a binary file?
|
static boolean |
isBinary(Reader in)
Do the first few bytes of the stream hint at a binary file?
|
static boolean |
isBinary(String name)
Is a file by that name a known binary file?
|
static boolean |
isBinaryData(String name) |
static boolean |
isBytecode(String name) |
static boolean |
isExecutable(String name) |
static boolean |
isImage(String name) |
static boolean |
isKeystore(String name) |
static boolean |
isNonBinary(String name)
Is a file by that name a known non-binary file?
|
public static final String[] DATA_EXTENSIONS
public static final String[] EXE_EXTENSIONS
public static final String[] KEYSTORE_EXTENSIONS
public static final String[] IMAGE_EXTENSIONS
public static final String[] BYTECODE_EXTENSIONS
public static final String[] NON_BINARY_EXTENSIONS
public static final String JAR_MANIFEST
public static final String JAVA
public static final int HIGH_BYTES_RATIO
public static final int TOTAL_READ_RATIO
public static final int NON_ASCII_THREASHOLD
public static final int ASCII_CHAR_THREASHOLD
public static boolean isBinary(Reader in)
Any IOException is swallowed internally and the test returns false.
This method may lead to false negatives if the reader throws an exception because it can't read characters according to the reader's encoding from the underlying stream.
public static boolean isBinary(InputStream in)
Any IOException is swallowed internally and the test returns false.
This method will try to read bytes from the stream and translate them to characters according to the platform's default encoding. If any bytes can not be translated to characters it will assume the original data must be binary and return true.
public static final boolean isBinaryData(String name)
public static final boolean isNonBinary(String name)
public static final boolean isExecutable(String name)
public static boolean isBytecode(String name)
public static final boolean isImage(String name)
public static final boolean isKeystore(String name)
public static final boolean isBinary(String name)
public static final boolean isBinary(Document document)
Copyright © 2006-2021 The Apache Software Foundation. All Rights Reserved.