使用其他功能(如 通过 Java 打开受密码保护的 MHTML 文档, 通过 Java 将 ODT 文档保存到数据库)将 MHTML 保存为 ODT 的情况较少。
// open encrypted document
Document document = new Document("input.mhtml", "password");
// save MHTML as a DOC
document.save("DocOutput.doc", SaveFormat.DOC);
public static void StoreToDatabase(Document doc, Connection mConnection) throws Exception {
// create an output stream which uses byte array to save data
ByteArrayOutputStream aout = new ByteArrayOutputStream();
// save the document to byte array
doc.save(aout, SaveFormat.ODT);
// get the byte array from output steam
// the byte array now contains the document
byte[] buffer = aout.toByteArray();
// get the filename from the document.
String fileName = doc.getOriginalFileName();
String filePath = fileName.replace("\\", "\\\\");
// create the SQL command.
String commandString = "INSERT INTO Documents (FileName, FileContent) VALUES('" + filePath + "', '" + buffer + "')";
Statement statement = mConnection.createStatement();
statement.executeUpdate(commandString);
}
使用 Java 开发 MHTML 文件转换应用程序
需要开发基于 Java 的软件应用程序来轻松保存和导出 MHTML 文件到 ODT 文档吗? 通过
Aspose.Total for Java
,任何Java开发人员都可以集成上述API代码来编写跨多种格式的转换应用程序,包括Microsoft Word(DOC、DOCX)、Excel(XLS、XLSX)、Powerpoint(PPT、PPTX)、PDF、电子邮件文件、图像(JPG、PNG、BMP、GIF)和其他格式。 强大的 Java 文档转换库,支持许多流行格式,包括 MHTML 格式。 将文档导出和渲染为其他格式,程序员可以使用 Aspose.Total for Java 子 API,包括
Aspose.Words for Java
、
Aspose.Cells for Java
、
Aspose.Slides for Java
、
Aspose.PDF for Java
、
Aspose.Imaging for Java
等。
MHTML Java 转换库
还有其他选项可以将 Aspose.Total for Java 集成到您的系统中。 请选择一个符合您需求的方案并按照分步说明进行操作:
- 直接从基于 Maven 的项目中使用 Aspose.Total for Java,并在 pom.xml 中包含相关子 API。
- 或者,可以从 下载 获取一个 ZIP 文件。
正在将 MHTML 保存至 ODT 应用要求
任何可以运行 Java 运行时环境 (JRE) 的操作系统都可以运行 Aspose.Total for Java。 以下列出了大多数(但不是全部)受支持的操作系统。
- 微软 Windows
- Linux:Ubuntu、OpenSUSE、CentOS 等
- macOS :10.9 (Mavericks) 及更高版本
- 移动设备:Android、iOS
关键用例
将Web内容存档为可编辑的ODT手册和指南。
在开源办公套件中进行协作项目文档编制。
将Web页面转换为教育材料和工作表。
利用ODT为全球团队准备多语言文档。
自动化场景
将基于MHTML的存档批量转换为ODT文件,以供分布式团队使用。
与开源CMS平台集成,实现自动文档生成。
定期转换以监控和报告Web内容。
从经常变化的Web资源自动更新的说明手册。