org.apache.tika.detect
Class TextDetector

java.lang.Object
  extended by org.apache.tika.detect.TextDetector
All Implemented Interfaces:
Detector

public class TextDetector
extends Object
implements Detector

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.

Note that text documents with a character encoding like UTF-16 are better detected with MagicDetector and an appropriate magic byte pattern.

Since:
Apache Tika 0.3

Constructor Summary
TextDetector()
           
 
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

TextDetector

public TextDetector()
Method Detail

detect

public MediaType detect(InputStream input,
                        Metadata metadata)
                 throws IOException
Looks at the beginning of the document input stream to determine whether the document is text or not.

Specified by:
detect in interface Detector
Parameters:
input - document input stream, or null
metadata - ignored
Returns:
"text/plain" if the input stream suggest a text document, "application/octet-stream" otherwise
Throws:
IOException - if the document input stream could not be read


Copyright © 2007-2010 The Apache Software Foundation. All Rights Reserved.