|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tika.detect.TextDetector
public class TextDetector
Content type detection of plain text documents. This detector looks at the beginning of the document input stream and considers the document to be a text document if no ASCII (ISO-Latin-1, UTF-8, etc.) control bytes are found. As a special case some control bytes (up to 2% of all characters) are also allowed in a text document if it also contains no or just a few (less than 10%) characters above the 7-bit ASCII range.
Note that text documents with a character encoding like UTF-16 are better
detected with MagicDetector
and an appropriate magic byte pattern.
Constructor Summary | |
---|---|
TextDetector()
Constructs a TextDetector which will look at the default number
of bytes from the beginning of the document. |
|
TextDetector(int bytesToTest)
Constructs a TextDetector which will look at a given number of
bytes from the beginning of the document. |
Method Summary | |
---|---|
MediaType |
detect(InputStream input,
Metadata metadata)
Looks at the beginning of the document input stream to determine whether the document is text or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TextDetector()
TextDetector
which will look at the default number
of bytes from the beginning of the document.
public TextDetector(int bytesToTest)
TextDetector
which will look at a given number of
bytes from the beginning of the document.
Method Detail |
---|
public MediaType detect(InputStream input, Metadata metadata) throws IOException
detect
in interface Detector
input
- document input stream, or null
metadata
- ignored
IOException
- if the document input stream could not be read
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |