Package org.apache.tika

Examples of org.apache.tika.Tika.detect()


      // mime-type, then guess a mime-type from the url pattern

      try {
        TikaConfig tikaConfig = TikaConfig.getDefaultConfig();
        Tika tika = new Tika(tikaConfig);
        retType = tika.detect(url) != null ? tika.detect(url) : null;
      } catch (Exception e) {
        String message = "Problem loading default Tika configuration";
        LOG.error(message, e);
        throw new RuntimeException(e);
      }
View Full Code Here


      // mime-type, then guess a mime-type from the url pattern

      try {
        TikaConfig tikaConfig = TikaConfig.getDefaultConfig();
        Tika tika = new Tika(tikaConfig);
        retType = tika.detect(url) != null ? tika.detect(url) : null;
      } catch (Exception e) {
        String message = "Problem loading default Tika configuration";
        LOG.error(message, e);
        throw new RuntimeException(e);
      }
View Full Code Here

    // if magic is enabled use mime magic to guess if the mime type returned
    // from the magic guess is different than the one that's already set so far
    // if it is, and it's not the default mime type, then go with the mime type
    // returned by the magic
    if (this.mimeMagic) {
      magicType = tika.detect(data);

      // Deprecated in Tika 1.0 See https://issues.apache.org/jira/browse/NUTCH-1230
      //MimeType magicType = this.mimeTypes.getMimeType(data);
      if (magicType != null && !magicType.equals(MimeTypes.OCTET_STREAM)
          && !magicType.equals(MimeTypes.PLAIN_TEXT)
View Full Code Here

    @Test
    public void testTikaBundle(BundleContext bc) throws Exception {
        Tika tika = new Tika();

        // Simple type detection
        assertEquals("text/plain", tika.detect("test.txt"));
        assertEquals("application/pdf", tika.detect("test.pdf"));

        // Simple text extraction
        String xml = tika.parseToString(new File("pom.xml"));
        assertTrue(xml.contains("tika-bundle"));
View Full Code Here

    public void testTikaBundle(BundleContext bc) throws Exception {
        Tika tika = new Tika();

        // Simple type detection
        assertEquals("text/plain", tika.detect("test.txt"));
        assertEquals("application/pdf", tika.detect("test.pdf"));

        // Simple text extraction
        String xml = tika.parseToString(new File("pom.xml"));
        assertTrue(xml.contains("tika-bundle"));
View Full Code Here

    @Test
    public void testTikaBundle() throws Exception {
        Tika tika = new Tika();

        // Simple type detection
        Assert.assertEquals("text/plain", tika.detect("test.txt"));
        Assert.assertEquals("application/pdf", tika.detect("test.pdf"));

        // Simple text extrction
        byte[] data = "Hello, World!".getBytes("UTF-8");
        Assert.assertEquals(
View Full Code Here

    public void testTikaBundle() throws Exception {
        Tika tika = new Tika();

        // Simple type detection
        Assert.assertEquals("text/plain", tika.detect("test.txt"));
        Assert.assertEquals("application/pdf", tika.detect("test.pdf"));

        // Simple text extrction
        byte[] data = "Hello, World!".getBytes("UTF-8");
        Assert.assertEquals(
                "Hello, World!",
View Full Code Here

    @Test
    public void testBundleDetection(BundleContext bc) throws Exception {
        Tika tika = new Tika();

        // Simple type detection
        assertEquals("text/plain", tika.detect("test.txt"));
        assertEquals("application/pdf", tika.detect("test.pdf"));
    }

    @Test
    public void testForkParser(BundleContext bc) throws Exception {
View Full Code Here

    public void testBundleDetection(BundleContext bc) throws Exception {
        Tika tika = new Tika();

        // Simple type detection
        assertEquals("text/plain", tika.detect("test.txt"));
        assertEquals("application/pdf", tika.detect("test.pdf"));
    }

    @Test
    public void testForkParser(BundleContext bc) throws Exception {
        ForkParser parser = (ForkParser) bc.getService(bc.getServiceReference(ForkParser.class.getName()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.