TIKA facade class detect() method is used to detect the document type based on the input file.
Example
In this program, we can detect file type based on the input file.
import java.io.File; import org.apache.tika.Tika; public class TikaTypeDetection { public static void main(String[] args) throws Exception { //Suppose hello.txt is in your current directory File file = new File("hello.txt");// //Instante tika facade class Tika tika = new Tika(); //detect file type using detect method String filetype = tika.detect(file); System.out.println(filetype); } }
Output
text/plain
You must log in to post a comment.