使用其他功能(如 通过 Java 打开受密码保护的 MHTML 文档, 通过 Java 将 RTF 文档保存到数据库)将 MHTML 保存为 RTF 的情况较少。
// 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.RTF);
// 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 文件到 RTF 文档吗? 通过
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 保存至 RTF 应用要求
任何可以运行 Java 运行时环境 (JRE) 的操作系统都可以运行 Aspose.Total for Java。 以下列出了大多数(但不是全部)受支持的操作系统。
- 微软 Windows
- Linux:Ubuntu、OpenSUSE、CentOS 等
- macOS :10.9 (Mavericks) 及更高版本
- 移动设备:Android、iOS
主要用途
保留格式的存档网页报告。
在多个文字处理软件中跨平台编辑网页内容。
共享格式化的基于网页的文档,无兼容性问题。
从在线来源准备带有样式文本的手册或指南。
自动化场景
定时批量转换用于网页内容存档。
集成到文档管理系统中,用于自动生成RTF。
自动转换用于需要RTF输入的遗留系统。
触发RTF创建,用于报告仪表板和自动化文档。