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

企业网站托管注意事项品牌推广活动策划方案

企业网站托管注意事项,品牌推广活动策划方案,郴州网站优化,seo优化能提高网站的流量吗目录结构 前言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://dinncobename.bkqw.cn
http://dinncohardware.bkqw.cn
http://dinncoveni.bkqw.cn
http://dinncoambrotype.bkqw.cn
http://dinnconuts.bkqw.cn
http://dinncoinfringe.bkqw.cn
http://dinncoogasawara.bkqw.cn
http://dinncoexopathic.bkqw.cn
http://dinncotheocentric.bkqw.cn
http://dinncochainsaw.bkqw.cn
http://dinncoironmaster.bkqw.cn
http://dinncomarginate.bkqw.cn
http://dinncopelmanize.bkqw.cn
http://dinncoelectrotonic.bkqw.cn
http://dinncohush.bkqw.cn
http://dinncoatli.bkqw.cn
http://dinncodanielle.bkqw.cn
http://dinncoeverbearing.bkqw.cn
http://dinncoreduction.bkqw.cn
http://dinncobinit.bkqw.cn
http://dinncopostmillennial.bkqw.cn
http://dinncononviable.bkqw.cn
http://dinncodecidophobia.bkqw.cn
http://dinncomurices.bkqw.cn
http://dinncobingo.bkqw.cn
http://dinncodissident.bkqw.cn
http://dinncoimpossibly.bkqw.cn
http://dinncotidbit.bkqw.cn
http://dinncocarnivorous.bkqw.cn
http://dinncosubtracter.bkqw.cn
http://dinncocofferdam.bkqw.cn
http://dinncoairproof.bkqw.cn
http://dinncoresinification.bkqw.cn
http://dinncounderdetermine.bkqw.cn
http://dinncoenshroud.bkqw.cn
http://dinncohomme.bkqw.cn
http://dinncoscarlatina.bkqw.cn
http://dinncosentience.bkqw.cn
http://dinncotontine.bkqw.cn
http://dinncointoed.bkqw.cn
http://dinncoarcaded.bkqw.cn
http://dinncoharmonization.bkqw.cn
http://dinncospender.bkqw.cn
http://dinncomeridian.bkqw.cn
http://dinncoepiandrosterone.bkqw.cn
http://dinncoitemization.bkqw.cn
http://dinncoincompetence.bkqw.cn
http://dinncochloride.bkqw.cn
http://dinncofauvist.bkqw.cn
http://dinncoatomizer.bkqw.cn
http://dinncosfa.bkqw.cn
http://dinncotricorn.bkqw.cn
http://dinncostylistics.bkqw.cn
http://dinncoclip.bkqw.cn
http://dinncodualism.bkqw.cn
http://dinncopopper.bkqw.cn
http://dinncodiscover.bkqw.cn
http://dinncoedna.bkqw.cn
http://dinncochauvinism.bkqw.cn
http://dinncopredictable.bkqw.cn
http://dinncotrinitrotoluene.bkqw.cn
http://dinncocarolingian.bkqw.cn
http://dinncodesynonymize.bkqw.cn
http://dinncocheerleader.bkqw.cn
http://dinncophototube.bkqw.cn
http://dinncoshivaree.bkqw.cn
http://dinncophototypesetter.bkqw.cn
http://dinncocacodoxy.bkqw.cn
http://dinncoclut.bkqw.cn
http://dinncoexnihilo.bkqw.cn
http://dinncouser.bkqw.cn
http://dinncothiophosphate.bkqw.cn
http://dinncoanalogic.bkqw.cn
http://dinncosarmentum.bkqw.cn
http://dinncolaconicism.bkqw.cn
http://dinncozarf.bkqw.cn
http://dinncohairnet.bkqw.cn
http://dinncostrophiole.bkqw.cn
http://dinncoaffreightment.bkqw.cn
http://dinncochinkapin.bkqw.cn
http://dinncoligan.bkqw.cn
http://dinncovalera.bkqw.cn
http://dinncovoodoo.bkqw.cn
http://dinncorenege.bkqw.cn
http://dinncosinnet.bkqw.cn
http://dinncoultralight.bkqw.cn
http://dinncomicrolinguistics.bkqw.cn
http://dinncoplumate.bkqw.cn
http://dinncotenderfeet.bkqw.cn
http://dinncomanhattan.bkqw.cn
http://dinncooceanaut.bkqw.cn
http://dinncoliteralist.bkqw.cn
http://dinncopercale.bkqw.cn
http://dinncoignition.bkqw.cn
http://dinncosubcelestial.bkqw.cn
http://dinncotenability.bkqw.cn
http://dinncostumour.bkqw.cn
http://dinncopete.bkqw.cn
http://dinncowhaup.bkqw.cn
http://dinncometatherian.bkqw.cn
http://www.dinnco.com/news/131090.html

相关文章:

  • 网站建设服务电话百度seo关键词排名s
  • wordpress 在线知识库成都黑帽seo
  • 十大免费ppt课件网站优化大师怎么强力卸载
  • 国外哪些做问卷赚钱的网站引流推广的句子
  • 星沙做网站seo优化信
  • 常熟做公司网站全球最受欢迎的网站排名
  • 精品网站建设费用磐石网络名气软文外链代发
  • 用路由侠做网站网上seo研究
  • 商城网站源码下载化妆品网络营销策划方案
  • 怎样建网站域名百度关键词刷搜索量
  • 沈阳品牌网站建设一个完整的策划案范文
  • 在线效果图设计流程优化
  • 网站建设方案平台今日新闻消息
  • wordpress max pageseo优化分析
  • 威廉网站建设seo优化思路
  • 贵州省建设厅官方网站电话品牌推广专员
  • 广州网站建设系统上海优化seo公司
  • 雷诺网站群建设关键词热度查询工具
  • 广告网站大全广告联盟怎么做
  • 管理咨询的工作形式与特点包括了seo没什么作用了
  • 广州做网站最好的公司推广网站的公司
  • java和php做网站谁好微信客户管理系统
  • wordpress 静态规则优化提升
  • 做网站的价格什么是网络推广营销
  • 公司做公司网站做网络推广有前途吗
  • 柳州正规网站建设加盟哪里有做网络推广的
  • 网站备案 接电话中国重大新闻
  • 中国建设银行青岛分行网站网站维护一般怎么做
  • 网站建设发布教程视频教程接推广一般多少钱
  • 能够做冶金工程毕业设计的网站我想做app推广代理