最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Apache tika 實(shí)現(xiàn)各種文檔內(nèi)容解析示例代碼

 更新時(shí)間:2024年07月10日 10:20:38   作者:北執(zhí)南念  
這篇文章主要介紹了Apache tika 實(shí)現(xiàn)各種文檔內(nèi)容解析,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧

Apache tika 實(shí)現(xiàn)各種文檔內(nèi)容解析

1、依賴(lài)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>cn.js</groupId>
    <artifactId>TikaResouce</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.0</version>
    </parent>
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.apache.tika</groupId>
                    <artifactId>tika-bom</artifactId>
                    <version>2.8.0</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-parsers-standard-package</artifactId>
        </dependency>
    </dependencies>
</project>

2、配置文件

新建一個(gè) tika-config.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<properties>
    <encodingDetectors>
        <encodingDetector class="org.apache.tika.parser.html.HtmlEncodingDetector">
            <params>
                <param name="markLimit" type="int">64000</param>
            </params>
        </encodingDetector>
        <encodingDetector class="org.apache.tika.parser.txt.UniversalEncodingDetector">
            <params>
                <param name="markLimit" type="int">64001</param>
            </params>
        </encodingDetector>
        <encodingDetector class="org.apache.tika.parser.txt.Icu4jEncodingDetector">
            <params>
                <param name="markLimit" type="int">64002</param>
            </params>
        </encodingDetector>
    </encodingDetectors>
</properties>

3、配置類(lèi)

package cn.js.config;
import java.io.IOException;
import java.io.InputStream;
import org.apache.tika.Tika;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.detect.Detector;
import org.apache.tika.exception.TikaException;
import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.parser.Parser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.xml.sax.SAXException;
/**
 * tika配置類(lèi)
 */
@Configuration
public class MyTikaConfig {
    @Autowired
    private ResourceLoader resourceLoader;
    @Bean
    public Tika tika() throws TikaException, IOException, SAXException {
        Resource resource = resourceLoader.getResource("classpath:tika-config.xml");
        InputStream inputStream = resource.getInputStream();
        TikaConfig config = new TikaConfig(inputStream);
        Detector detector = config.getDetector();
        Parser autoDetectParser = new AutoDetectParser(config);
        return new Tika(detector, autoDetectParser);
    }
}

controller

package cn.js.controller;
import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
@RestController
@RequestMapping("/tika")
public class TikaController {
    @Resource
    private Tika tika;
    @PostMapping("/pdf")
    public void TikaDemon(@RequestParam("file") MultipartFile file) throws IOException, TikaException {
        InputStream inputStream = file.getInputStream();
        String s = tika.parseToString(inputStream);
        System.out.println(s);
    }
}

到此這篇關(guān)于Apache tika 實(shí)現(xiàn)各種文檔內(nèi)容解析的文章就介紹到這了,更多相關(guān)Apache tika 文檔內(nèi)容解析內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • apache ab工具頁(yè)面壓力測(cè)試返回結(jié)果含義解釋

    apache ab工具頁(yè)面壓力測(cè)試返回結(jié)果含義解釋

    這篇文章主要介紹了apache ab工具頁(yè)面壓力測(cè)試返回結(jié)果含義解釋,ab工具的使用非常簡(jiǎn)單,但返回結(jié)果中的數(shù)據(jù)有點(diǎn)多,看不懂的話(huà)就需要看看本文了,需要的朋友可以參考下
    2015-07-07
  • 一道題理解Linux中sort命令的多個(gè)參數(shù)

    一道題理解Linux中sort命令的多個(gè)參數(shù)

    今天小編就為大家分享一篇關(guān)于一道題理解Linux中sort命令的多個(gè)參數(shù),小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-03-03
  • Centos7安裝redis6.2.6全過(guò)程

    Centos7安裝redis6.2.6全過(guò)程

    本文介紹了在CentOS7上安裝Redis的過(guò)程,包括下載、安裝依賴(lài)(gcc)、解壓編譯安裝、修改配置、啟動(dòng)服務(wù)及自啟配置等步驟
    2026-04-04
  • 每天一個(gè)linux命令(61):wget命令詳解

    每天一個(gè)linux命令(61):wget命令詳解

    本篇文章主要介紹了wget命令,Linux系統(tǒng)中的wget是一個(gè)下載文件的工具,非常具有實(shí)用價(jià)值,需要的朋友可以參考下。
    2016-11-11
  • linux下安裝nodejs及npm的方法

    linux下安裝nodejs及npm的方法

    本篇文章主要介紹了linux下安裝nodejs及npm的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-06-06
  • 阿里云CentOS掛載新數(shù)據(jù)盤(pán)的方法

    阿里云CentOS掛載新數(shù)據(jù)盤(pán)的方法

    本篇文章主要介紹了阿里云CentOS掛載新數(shù)據(jù)盤(pán)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-12-12
  • CentOS下MySQL的徹底卸載的幾種方法

    CentOS下MySQL的徹底卸載的幾種方法

    本篇文章主要介紹了CentOS下MySQL的徹底卸載的幾種方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-08-08
  • Linux進(jìn)程地址空間的使用及說(shuō)明

    Linux進(jìn)程地址空間的使用及說(shuō)明

    Linux進(jìn)程地址空間通過(guò)VMA和mm_struct管理,包含代碼段、數(shù)據(jù)段、堆棧、mmap等區(qū)域,利用頁(yè)表實(shí)現(xiàn)隔離,處理缺頁(yè)異常,支持匿名與文件映射,系統(tǒng)調(diào)用如brk/mmap用于內(nèi)存分配與管理
    2025-08-08
  • linux的CPU、內(nèi)存查看命令方式

    linux的CPU、內(nèi)存查看命令方式

    這篇文章主要介紹了linux的CPU、內(nèi)存查看命令方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-07-07
  • 手把手教你在騰訊云上搭建hive3.1.2的方法

    手把手教你在騰訊云上搭建hive3.1.2的方法

    這篇文章主要介紹了手把手教你在騰訊云上搭建hive3.1.2的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07

最新評(píng)論

江陵县| 大连市| 渭源县| 秭归县| 顺昌县| 桓台县| 南部县| 兴安县| 渭南市| 开封县| 通化县| 商洛市| 安宁市| 马鞍山市| 宁远县| 那坡县| 军事| 固始县| 莱芜市| 奎屯市| 南召县| 莱西市| 洛川县| 东宁县| 永兴县| 大厂| 西和县| 开原市| 南川市| 北京市| 全州县| 沙雅县| 封开县| 梁山县| 怀来县| 丰城市| 教育| 松江区| 黎川县| 邵东县| 固阳县|