我用:
soffice -headless -accept="socket,port=8100;urp;"
命令启动OpenOffice,然后在程序中
public void run() {
// 创建Openoffice连接
OpenOfficeConnection con=null;
long newsooc_s=System.currentTimeMillis();
con = new SocketOpenOfficeConnection(8100);
try {
// 连接
long con_s=System.currentTimeMillis();
con.connect();
long con_e=System.currentTimeMillis();
System.out.println(this.getName()+" "+con.isConnected()+"'con.connect: "+con_e+"-"+con_s+"=0."+(con_e-con_s)%1000+"秒");
} catch (Exception e) {
System.out.println("获取OpenOffice连接失败...");
e.printStackTrace();
}
// 创建转换器
DocumentConverter converter = new OpenOfficeDocumentConverter(con);
// 转换文档html
String fn = "E:/test_oo/Fintelligen_"+this.hashCode()+ ".html";
converter.convert(new File("E:/test_oo/Fintelligen.xls"), new File(fn));
long dc_e=System.currentTimeMillis();
System.out.println(this.getName()+"'converter.convert: "+dc_e+"-"+newsooc_s+"="+(dc_e-newsooc_s)/1000+"."+(dc_e-newsooc_s)%1000+"秒");
// 关闭openoffice连接
con.disconnect();
}
这样就会使后台的openoffice内存不断变大,好像链接没有释放。
请大虾解决一下内存问题。