From fcbb4da4baa3e48a8be615b02a1eb8ad05280378 Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 6 Oct 2020 18:45:22 +0200 Subject: [PATCH] Initial commit --- .gitignore | 1 + pom.xml | 80 ++++++++++++++++++++++ shell.nix | 5 ++ src/main/java/org/RI/P1/EjemploSimple.java | 22 ++++++ 4 files changed, 108 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 shell.nix create mode 100644 src/main/java/org/RI/P1/EjemploSimple.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b75f0cb --- /dev/null +++ b/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + org.RI.P1 + P1 + 1.0-SNAPSHOT + + P1 + + http://www.example.com + + + UTF-8 + 1.7 + 1.7 + + + + + junit + junit + 4.11 + test + + + org.apache.tika + tika-core + 1.22 + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..d78b1ca --- /dev/null +++ b/shell.nix @@ -0,0 +1,5 @@ +{ pkgs ? import { } }: + +with pkgs; + +mkShell { buildInputs = [ jdk11 maven ]; } diff --git a/src/main/java/org/RI/P1/EjemploSimple.java b/src/main/java/org/RI/P1/EjemploSimple.java new file mode 100644 index 0000000..dba1be8 --- /dev/null +++ b/src/main/java/org/RI/P1/EjemploSimple.java @@ -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); + } + } +} +