gpt4 book ai didi

java - 如何更新 DOC 中的关键字元数据

转载 作者:行者123 更新时间:2023-12-01 12:30:57 24 4
gpt4 key购买 nike

我正在尝试更新 DOC 文件元数据中的关键字。我已经能够使用下面的代码更新category元数据,但我没有看到任何更改keywords

的方法

我正在使用poi:3.10-FINAL

void updateProperties(String filepath) {
POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(filepath));
DirectoryEntry dir = poifs.getRoot();
DocumentSummaryInformation dsi;
try
{
DocumentEntry dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
DocumentInputStream dis = new DocumentInputStream(dsiEntry);
PropertySet ps = new PropertySet(dis);
dis.close();
dsi = new DocumentSummaryInformation(ps);
}
catch (FileNotFoundException ex)
{
dsi = PropertySetFactory.newDocumentSummaryInformation();
}
dsi.setCategory("New Category set");


dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
OutputStream out = new FileOutputStream(filepath);
poifs.writeFilesystem(out);
out.close();
}

最佳答案

关键字不存储在 DocumentSummaryInformation 中,而是存储在另一个属性流中,即 SummaryInformation

如果您查看 JavaDocs SummaryInformation ,你会看到它有方法 setKeywords(String)您搜索的内容!

关于java - 如何更新 DOC 中的关键字元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25925790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com