java using的用法

编程入门 行业动态 更新时间:2024-10-23 19:32:07

<a href=https://www.elefans.com/category/jswz/34/1770091.html style=java using的用法"/>

java using的用法

如何使用java从PDF中提取内容。(How to extract content from an ODF using java.)

问题描述 (Problem Description)

如何使用java从ODF中提取内容。

解决方案 (Solution)

以下是使用java从ODF中提取内容的程序。import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import org.apache.tika.exception.TikaException;

import org.apache.tika.metadata.Metadata;

import org.apache.tika.parser.ParseContext;

import org.apache.tika.parser.odf.OpenDocumentParser;

import org.apache.tika.sax.BodyContentHandler;

import org.xml.sax.SAXException;

public class ExtractContentFromODF {

public static void main(String[] args) throws Exception {

//detecting the file type

BodyContentHandler handler = new BodyContentHandler();

Metadata metadata = new Metadata();

FileInputStream inputstream = new FileInputStream(new File(

"C:/tika/odfExample.odt"));

ParseContext pcontext = new ParseContext();

//Open Document Parser

OpenDocumentParser openofficeparser = new OpenDocumentParser ();

openofficeparser.parse(inputstream, handler, metadata,pcontext);

System.out.println("Contents of the document:" + handler.toString());

System.out.println("Metadata of the document:");

String[] metadataNames = metadata.names();

for(String name : metadataNames) {

System.out.println(name + " : " + metadata.get(name));

}

}

}

输入 (Input)

输出 (Output)Contents of the document: IOWIKI originated from the idea that there exists a

class of readers who respond better to online content and prefer to learn new skills

at their own pace from the comforts of their drawing rooms.

The journey commenced with a single tutorial on HTML in 2006 and elated by the response

it generated, we worked our way to adding fresh tutorials to our repository which now

proudly flaunts a wealth of tutorials and allied articles on topics ranging from

programming languages to web designing to academics and much more.

Metadata of the document:

date : 2017-05-19T09:03:00Z

meta:paragraph-count : 1

meta:word-count : 78

meta:initial-author : krishnakasyap Bhagavatula

initial-creator : krishnakasyap Bhagavatula

dc:creator : krishnakasyap Bhagavatula

generator : MicrosoftOffice/15.0 MicrosoftWord

Word-Count : 78

dcterms:created : 2017-05-19T09:03:00Z

dcterms:modified : 2017-05-19T09:03:00Z

Last-Modified : 2017-05-19T09:03:00Z

nbPara : 1

Last-Save-Date : 2017-05-19T09:03:00Z

meta:character-count : 528

Paragraph-Count : 1

meta:save-date : 2017-05-19T09:03:00Z

modified : 2017-05-19T09:03:00Z

Edit-Time : PT0S

nbCharacter : 528

nbPage : 1

nbWord : 78

Content-Type : application/vnd.oasis.opendocument.text

creator : krishnakasyap Bhagavatula

meta:author : krishnakasyap Bhagavatula

meta:creation-date : 2017-05-19T09:03:00Z

Creation-Date : 2017-05-19T09:03:00Z

xmpTPg:NPages : 1

Character Count : 528

editing-cycles : 2

Page-Count : 1

Author : krishnakasyap Bhagavatula

meta:page-count : 1

更多推荐

java using的用法

本文发布于:2024-02-26 14:23:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1702816.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!