|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.j256.simplemagic.ContentInfoUtil
public class ContentInfoUtil
Class which reads in the magic files and determines the ContentInfo
for files and byte arrays. You use the
default constructor ContentInfoUtil()
to use the internal rules file or load in a local file from the
file-system using ContentInfoUtil(String)
. Once the rules are loaded, you use findMatch(String)
or
other such methods to get the content-type of a file or bytes.
Nested Class Summary | |
---|---|
static interface |
ContentInfoUtil.ErrorCallBack
While we are parsing the magic configuration files, there are usually tons of badly formed lines and other errors. |
Constructor Summary | |
---|---|
ContentInfoUtil()
Construct a magic utility using the internal magic file built into the package. |
|
ContentInfoUtil(ContentInfoUtil.ErrorCallBack errorCallBack)
Construct a magic utility using the internal magic file built into the package. |
|
ContentInfoUtil(File fileOrDirectory)
Construct a magic utility using the magic files from a file or a directory of files. |
|
ContentInfoUtil(File fileOrDirectory,
ContentInfoUtil.ErrorCallBack errorCallBack)
Construct a magic utility using the magic files from a file or a directory of files. |
|
ContentInfoUtil(String fileOrDirectoryPath)
Construct a magic utility using the magic files from a file or a directory of files. |
|
ContentInfoUtil(String fileOrDirectoryPath,
ContentInfoUtil.ErrorCallBack errorCallBack)
Construct a magic utility using the magic files from a file or a directory of files. |
Method Summary | |
---|---|
ContentInfo |
findMatch(byte[] bytes)
Return the content type from the associated bytes or null if none of the magic entries matched. |
ContentInfo |
findMatch(File file)
Return the content type for the file or null if none of the magic entries matched. |
ContentInfo |
findMatch(InputStream inputStream)
Return the content type for the input-stream or null if none of the magic entries matched. |
ContentInfo |
findMatch(String filePath)
Return the content type for the file or null if none of the magic entries matched. |
void |
setErrorCallBack(ContentInfoUtil.ErrorCallBack errorCallBack)
Set our class which will get called whenever we get a configuration error. |
void |
setFileReadSize(int fileReadSize)
Set the default size that will be read if we are getting the content from a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ContentInfoUtil()
IllegalStateException
- If there was a problem reading the magic entries from the internal magic file.public ContentInfoUtil(ContentInfoUtil.ErrorCallBack errorCallBack)
IllegalStateException
- If there was a problem reading the magic entries from the internal magic file.public ContentInfoUtil(String fileOrDirectoryPath) throws IOException
IOException
- If there was a problem reading the magic entries from the internal magic file.public ContentInfoUtil(String fileOrDirectoryPath, ContentInfoUtil.ErrorCallBack errorCallBack) throws IOException
IOException
- If there was a problem reading the magic entries from the internal magic file.public ContentInfoUtil(File fileOrDirectory) throws IOException
IOException
- If there was a problem reading the magic entries from the internal magic file.public ContentInfoUtil(File fileOrDirectory, ContentInfoUtil.ErrorCallBack errorCallBack) throws IOException
IOException
- If there was a problem reading the magic entries from the internal magic file.Method Detail |
---|
public ContentInfo findMatch(String filePath) throws IOException
IOException
- If there was a problem reading from the file.public ContentInfo findMatch(File file) throws IOException
IOException
- If there was a problem reading from the file.public ContentInfo findMatch(InputStream inputStream) throws IOException
NOTE: The caller is responsible for closing the input-stream.
IOException
- If there was a problem reading from the input-stream.public ContentInfo findMatch(byte[] bytes)
public void setFileReadSize(int fileReadSize)
public void setErrorCallBack(ContentInfoUtil.ErrorCallBack errorCallBack)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |