Initial commit
This commit is contained in:
22
src/main/java/org/RI/P1/EjemploSimple.java
Normal file
22
src/main/java/org/RI/P1/EjemploSimple.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import java.io.File;
|
||||
import org.apache.tika.Tika ;
|
||||
|
||||
public class EjemploSimple {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Creamos una instancia de Tika con la configuracion por defecto
|
||||
Tika tika = new Tika();
|
||||
// Se parsean los ficheros pasados como argumento y se extrae el contenido
|
||||
for (String file : args) {
|
||||
File f = new File(file);
|
||||
// Detectamos el MIME tipo del fichero
|
||||
String type = tika.detect(f);
|
||||
System.out.println(file +":"+type);
|
||||
// Extraemos el texto plano en un string
|
||||
String text = tika.parseToString(f);
|
||||
System.out.print(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user