我正在尝试使用JODConverter从上传的“.docx”文件生成 PDF 文档。对生成 PDF 的方法的调用是这样的:
File inputFile = new File("document.doc");
File outputFile = new File("document.pdf");
// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
// close the connection
connection.disconnect();
我正在使用 apache commons FileUpload来处理 docx 文件的上传,我可以从中获取 InputStream 对象。我知道这Java.io.File
只是对系统中文件的抽象引用。
我想避免磁盘写入(将 InputStream 保存到磁盘)和磁盘读取(读取 JODConverter 中保存的文件)。
有什么方法可以获取引用输入流的 File 对象吗?任何其他避免磁盘 IO 的方法也可以!
编辑:我不在乎这是否会最终使用大量系统内存。该应用程序将托管在一个只有很少到零数量的并行用户的 LAN 上。