public class BinaryGuesser extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ASCII_CHAR_THREASHOLD |
static int |
HIGH_BYTES_RATIO |
static String |
JAR_MANIFEST |
static String |
JAVA |
static int |
NON_ASCII_THREASHOLD |
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) |
static boolean |
isBinary(Reader in) |
static boolean |
isBinary(String name) |
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) |
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)
in
- the file to check.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)
in
- the file to check.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)
name
- current file name.public static final boolean isNonBinary(String name)
name
- current file name.public static final boolean isExecutable(String name)
name
- current file 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)
name
- file name.public static final boolean isBinary(Document document)
Copyright © 2006–2016 Apache Software Foundation. All rights reserved.