当前位置: 首页 > news >正文

企业网站托管一年多少钱网络广告联盟

企业网站托管一年多少钱,网络广告联盟,做商城网站公司吗,手表网站起名目录结构 前言tika简介Tika支持的文件格式MAVEN依赖JAVA程序JAVA测试程序测试文件测试结果部分文件提取失败参考连接 前言 Apache Tika提取文件整理如下,如有特定的文件需要提取可以先参照【部分文件提取失败】章节对照,以免浪费您的宝贵时间&#xff0c…

目录结构

    • 前言
    • tika简介
    • Tika支持的文件格式
    • MAVEN依赖
    • JAVA程序
    • JAVA测试程序
    • 测试文件
    • 测试结果
    • 部分文件提取失败
    • 参考连接

前言

在这里插入图片描述

Apache Tika提取文件整理如下,如有特定的文件需要提取可以先参照【部分文件提取失败】章节对照,以免浪费您的宝贵时间,如有问题或者解决办法还望大牛不吝赐教,小编在此谢过!

tika简介

Tika全名Apache Tika,是用于文件类型检测和从各种格式的文件中提取内容的一个库。
Tika使用现有的各种文件解析器和文档类型的检测技术来检测和提取数据。
使用Tika,可以轻松提取到的不同类型的文件内容,如电子表格,文本文件,图像,PDF文件甚至多媒体输入格式,在一定程度上提取结构化文本以及元数据。
统一解析器接口:Tika封装在一个单一的解析器接口的第三方解析器库。由于这个特征,用户逸出从选择合适的解析器库的负担,并使用它,根据所遇到的文件类型。
使用的Tika facade类是从Java调用Tika的最简单和直接的方式,而且也沿用了外观的设计模式。可以在 Tika API的org.apache.tika包Tika 找到外观facade类。
Tika提供用于解析不同文件格式的一个通用API。它采用83个现有的专业解析器库,所有这些解析器库是根据一个叫做Parser接口单一接口封装。

Tika支持的文件格式

文件格式类库Tika中的类
XMLorg.apache.tika.parser.xmlXMLParser
HTMLorg.apache.tika.parser.htmll and it uses Tagsoup LibraryHtmlParser
MS-Office compound document Ole2 till 2007 ooxml 2007 onwardsorg.apache.tika.parser.microsoftorg.apache.tika.parser.microsoft.ooxml and it uses Apache Poi libraryOfficeParser(ole2)OOXMLParser(ooxml)
OpenDocument Format openofficeorg.apache.tika.parser.odfOpenOfficeParser
portable Document Format(PDF)org.apache.tika.parser.pdf and this package uses Apache PdfBox libraryPDFParser
Electronic Publication Format (digital books)org.apache.tika.parser.epubEpubParser
Rich Text formatorg.apache.tika.parser.rtfRTFParser
Compression and packaging formatsorg.apache.tika.parser.pkg and this package uses Common compress libraryPackageParser and CompressorParser and its sub-classes
Text formatorg.apache.tika.parser.txtTXTParser
Feed and syndication formatsorg.apache.tika.parser.feedFeedParser
Audio formatsorg.apache.tika.parser.audio and org.apache.tika.parser.mp3AudioParser MidiParser Mp3- for mp3parser
Imageparsersorg.apache.tika.parser.jpegJpegParser-for jpeg images
Videoformatsorg.apache.tika.parser.mp4 and org.apache.tika.parser.video this parser internally uses Simple Algorithm to parse flash video formatsMp4parser FlvParser
java class files and jar filesorg.apache.tika.parser.asmClassParser CompressorParser
Mobxformat (email messages)org.apache.tika.parser.mboxMobXParser
Cad formatsorg.apache.tika.parser.dwgDWGParser
FontFormatsorg.apache.tika.parser.fontTrueTypeParser
executable programs and librariesorg.apache.tika.parser.executableExecutableParser

MAVEN依赖

目前已经有2.8.0版本,有兴趣的朋友可以尝试一下,使用感受可以和小编交流一下哦~

<repositories><repository><id>com.e-iceblue</id><name>e-iceblue</name><url>http://repo.e-iceblue.com/nexus/content/groups/public/</url></repository>
</repositories><dependencies><dependency><groupId>org.apache.tika</groupId><artifactId>tika-parsers</artifactId><version>1.24</version></dependency><dependency><groupId>org.apache.tika</groupId><artifactId>tika-core</artifactId><version>1.24</version></dependency>
</dependencies>

JAVA程序

package com.xxx.xxx.carry;import cn.hutool.core.lang.UUID;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import org.apache.commons.io.FilenameUtils;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.detect.Detector;
import org.apache.tika.exception.TikaException;
import org.apache.tika.extractor.EmbeddedDocumentExtractor;
import org.apache.tika.extractor.ParsingEmbeddedDocumentExtractor;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MediaType;
import org.apache.tika.mime.MimeTypeException;
import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.Parser;
import org.apache.tika.sax.BodyContentHandler;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;public class CarryingFileUtils {// 创建解析器,使用AutoDetectParser可以自动检测一个最合适的解析器private static Parser parser = new AutoDetectParser();private static Detector detector = ((AutoDetectParser) parser).getDetector();private static TikaConfig config = TikaConfig.getDefaultConfig();public static void extract(InputStream is, Path outputDir) throws SAXException, TikaException, IOException {Metadata m = new Metadata();// 指定最基本的变量信息(即存放一个所使用的解析器对象)ParseContext c = new ParseContext();BodyContentHandler h = new BodyContentHandler(-1);c.set(Parser.class, parser);EmbeddedDocumentExtractor ex = new MyEmbeddedDocumentExtractor(outputDir, c);c.set(EmbeddedDocumentExtractor.class, ex);// InputStream-----指定文件输入流// ContentHandler--指定要解析文件的哪一个内容,它有一个实现类叫做BodyContentHandler,即专门用来解析文档内容的// Metadata--------指定解析文件时,存放解析出来的元数据的Metadata对象// ParseContext----该对象用于存放一些变量信息,该对象最少也要存放所使用的解析器对象,这也是其存放的最基本的变量信息parser.parse(is, h, m, c);}private static class MyEmbeddedDocumentExtractor extends ParsingEmbeddedDocumentExtractor {private final Path outputDir;private int fileCount = 0;private MyEmbeddedDocumentExtractor(Path outputDir, ParseContext context) {super(context);this.outputDir = outputDir;}@Overridepublic boolean shouldParseEmbedded(Metadata metadata) {return true;}@Overridepublic void parseEmbedded(InputStream stream, ContentHandler handler, Metadata metadata, boolean outputHtml) throws IOException {//try to get the name of the embedded file from the metadataString name = metadata.get(Metadata.RESOURCE_NAME_KEY);if (name == null) {name = "file_" + fileCount++;} else {//make sure to select only the file name (not any directory paths//that might be included in the name) and make sure//to normalize the namename = name.replaceAll("\u0000", " ");int prefix = FilenameUtils.getPrefixLength(name);if (prefix > -1) {name = name.substring(prefix);}name = FilenameUtils.normalize(FilenameUtils.getName(name));}//now try to figure out the right extension for the embedded fileMediaType contentType = detector.detect(stream, metadata);if (name.indexOf('.') == -1 && contentType != null) {try {name += config.getMimeRepository().forName(contentType.toString()).getExtension();} catch (MimeTypeException e) {e.printStackTrace();}}// 夹带文件名编码格式调整name = new String(name.getBytes("ISO-8859-1"), "GBK");Path outputFile = outputDir.resolve(name);if (Files.exists(outputFile)) {outputFile = outputDir.resolve(UUID.randomUUID().toString() + "-" + name);}Files.createDirectories(outputFile.getParent());String formart = name.substring(name.lastIndexOf(".") + 1).toUpperCase();// 去除无关文件if (!"EMF,WMF".contains(formart)) {Files.copy(stream, outputFile);}}}
}

JAVA测试程序

package com.xxx.xxx.utils;import com.xxx.xxx.carry.CarryingFileUtils;import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;public class Jkx {public static void main(String[] args) {// 提取文件String inputFilrPath = "C:\\Users\\Administrator\\Desktop\\file_check\\qiantao\\Excel文件嵌套doc.xlsx";// 输出文件路径String outFilePath = "C:\\Users\\Administrator\\Desktop\\file_check\\nest_file\\";try {InputStream inputStream = new BufferedInputStream(new FileInputStream(inputFilrPath));Path outFileUrl = Paths.get(outFilePath);CarryingFileUtils.extract(inputStream, outFileUrl);} catch (Exception e) {e.printStackTrace();}}
}

测试文件

测试文件_百度网盘提取链接
在这里插入图片描述

测试结果

在这里插入图片描述
在这里插入图片描述

部分文件提取失败

提取失败文件整理如下,如有大牛有解决办法还望不吝赐教:

文件类型嵌套文件类型
.dot.doc
.doc.docm
.doc.wps
.wps.wps
.xls.xls
.et.et
.xls.et
.xltm.ett
.pps.ppt
.html.wps
.mht.wps
.mhtml.wps
.pot.pot
.cebx.*
.dot.doc
.dps.dps
.pptx.dps
.dpt.dps
.docx.eid
.doc.eis
.png.odp
.png.ods
.png.odt

参考连接

  1. https://www.jianshu.com/p/407735f03094?v=1672195773961

文章转载自:
http://dinncoexcusingly.wbqt.cn
http://dinncounqueen.wbqt.cn
http://dinncosnakeless.wbqt.cn
http://dinncoxanthian.wbqt.cn
http://dinncolambdoidal.wbqt.cn
http://dinncoordination.wbqt.cn
http://dinncopolysyndeton.wbqt.cn
http://dinncolsat.wbqt.cn
http://dinncolushly.wbqt.cn
http://dinncogutturalize.wbqt.cn
http://dinncohypnotic.wbqt.cn
http://dinncocelestially.wbqt.cn
http://dinncoflannelly.wbqt.cn
http://dinncochanticleer.wbqt.cn
http://dinncotoady.wbqt.cn
http://dinncopockmarked.wbqt.cn
http://dinncorebreathe.wbqt.cn
http://dinncosledge.wbqt.cn
http://dinncorage.wbqt.cn
http://dinncoascender.wbqt.cn
http://dinncofade.wbqt.cn
http://dinncojocularity.wbqt.cn
http://dinncoalger.wbqt.cn
http://dinncofluorimeter.wbqt.cn
http://dinncochemosterilant.wbqt.cn
http://dinncospeedup.wbqt.cn
http://dinncohungeringly.wbqt.cn
http://dinncopuka.wbqt.cn
http://dinncoinsufficiently.wbqt.cn
http://dinncoanandrous.wbqt.cn
http://dinncoseptenary.wbqt.cn
http://dinncoraca.wbqt.cn
http://dinnconeedy.wbqt.cn
http://dinncolapicide.wbqt.cn
http://dinncokhuskhus.wbqt.cn
http://dinncodelightedly.wbqt.cn
http://dinncospermalege.wbqt.cn
http://dinncopaleolatitude.wbqt.cn
http://dinncotollhouse.wbqt.cn
http://dinncoexecutioner.wbqt.cn
http://dinncoresorption.wbqt.cn
http://dinncoliberaloid.wbqt.cn
http://dinncojugum.wbqt.cn
http://dinncopreacher.wbqt.cn
http://dinncoexclusively.wbqt.cn
http://dinncosquirish.wbqt.cn
http://dinncohotch.wbqt.cn
http://dinncoappease.wbqt.cn
http://dinncoarris.wbqt.cn
http://dinncoarchaize.wbqt.cn
http://dinncoblackie.wbqt.cn
http://dinnconagger.wbqt.cn
http://dinncodermatropic.wbqt.cn
http://dinncokozhikode.wbqt.cn
http://dinncopreglacial.wbqt.cn
http://dinncoanalog.wbqt.cn
http://dinncoevalina.wbqt.cn
http://dinncoxingu.wbqt.cn
http://dinncosluttish.wbqt.cn
http://dinncopup.wbqt.cn
http://dinncosnopesian.wbqt.cn
http://dinncogenethliac.wbqt.cn
http://dinncohappen.wbqt.cn
http://dinncopertinently.wbqt.cn
http://dinncolaager.wbqt.cn
http://dinnconewsy.wbqt.cn
http://dinncoinfrangibility.wbqt.cn
http://dinncopaisley.wbqt.cn
http://dinncolactogen.wbqt.cn
http://dinncocranage.wbqt.cn
http://dinncoswami.wbqt.cn
http://dinncoptosis.wbqt.cn
http://dinncostreptolysin.wbqt.cn
http://dinncosilicicolous.wbqt.cn
http://dinncofixate.wbqt.cn
http://dinncococcygeal.wbqt.cn
http://dinncomtu.wbqt.cn
http://dinncopreliminary.wbqt.cn
http://dinncoexcursionist.wbqt.cn
http://dinncomaculation.wbqt.cn
http://dinncoble.wbqt.cn
http://dinncohabitancy.wbqt.cn
http://dinncoiosb.wbqt.cn
http://dinncoleben.wbqt.cn
http://dinncophyle.wbqt.cn
http://dinncodebenture.wbqt.cn
http://dinncobeady.wbqt.cn
http://dinncoglitter.wbqt.cn
http://dinncohandcraft.wbqt.cn
http://dinncorighty.wbqt.cn
http://dinncoexergue.wbqt.cn
http://dinncocon.wbqt.cn
http://dinncokabele.wbqt.cn
http://dinncoanbury.wbqt.cn
http://dinncobleb.wbqt.cn
http://dinncosallet.wbqt.cn
http://dinncoassuage.wbqt.cn
http://dinncooptionally.wbqt.cn
http://dinncohyperpyrexia.wbqt.cn
http://dinncoscreenwiper.wbqt.cn
http://www.dinnco.com/news/127091.html

相关文章:

  • 建设厅网站查询seo去哪学
  • 网站建设 广州客户引流的最快方法是什么
  • 做网站推广的需要了解哪些知识百度搜索次数统计
  • 安阳网站建设优化关键词分为哪几类
  • 网站服务器错误低价刷粉网站推广
  • 女士手表网站优化公司组织架构
  • 北京建设制作网站广州seo排名收费
  • 郑州关键词seoseo有哪些作用
  • github 做网站百度推广开户渠道
  • 网上怎么注册网址安卓优化大师最新版
  • 抚州南城网站建设小程序seo推广技巧
  • 保定哪有做网站的seoul怎么读
  • 鄂尔多斯 网站建设怎么自己创建网址
  • 如何鉴别网站有没有做301重定向黄页88网
  • 昆山设计网站公司爱用建站
  • vs和dw做网站的区别百度做网站
  • 网站app公众号先做哪个比较好搜索排行榜
  • 南宁网站制作建设百度推广服务费3000元
  • b to b 网站建站关键词优化
  • 哪里有做旅游包车的网站贷款客户大数据精准获客
  • 新疆做网站找谁站长之家的作用
  • 经典网站设计seo流量排名软件
  • 南京广告公司户外广告seo关键词找29火星软件
  • 新疆生产建设兵团纪检监察网站网站制作公司咨询
  • 潍坊做网站公司网络营销主要做些什么
  • 临清网站建设网络营销工具包括
  • 鲅鱼圈做网站上海seo怎么优化
  • 重庆建设工程证照查询网站西安网站维护公司
  • 湛江制作企业网站百度推广服务
  • 中国建设网官方网站发改委东莞网站seo公司