• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SocketOpenOfficeConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection的典型用法代码示例。如果您正苦于以下问题:Java SocketOpenOfficeConnection类的具体用法?Java SocketOpenOfficeConnection怎么用?Java SocketOpenOfficeConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SocketOpenOfficeConnection类属于com.artofsolving.jodconverter.openoffice.connection包,在下文中一共展示了SocketOpenOfficeConnection类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: convert

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
/**
 * 将word文档转换成html文档
 * 
 * @param docFile
 *            需要转换的word文档
 * @param filepath
 *            转换之后html的存放路径
 * @return 转换之后的html文件
 */
public static File convert(File docFile, String filepath) {
	// 创建保存html的文件
	File htmlFile = new File(filepath + "/" + new Date().getTime()
			+ ".html");
	// 创建Openoffice连接
	OpenOfficeConnection con = new SocketOpenOfficeConnection(8100);
	try {
		// 连接
		con.connect();
		System.out.println("获取OpenOffice连接成功...");
	} catch (ConnectException e) {
		System.out.println("获取OpenOffice连接失败...");
		e.printStackTrace();
	}
	// 创建转换器
	DocumentConverter converter = new OpenOfficeDocumentConverter(con);
	// 转换文档问html
	converter.convert(docFile, htmlFile);
	// 关闭openoffice连接
	con.disconnect();
	return htmlFile;
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:32,代码来源:Doc2Html.java


示例2: OpenOfficePrintingService

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
public OpenOfficePrintingService(String host, int port, String outputFormat) {
    Preconditions.checkNotNull(host, "Invalid host.");
    Preconditions.checkArgument(!host.isEmpty(), "Invalid host.");
    Preconditions.checkArgument(port >= 0, "Invalid port.");
    Preconditions.checkArgument(port <= 65535, "Invalid port.");
    Preconditions.checkNotNull(outputFormat, "Invalid output format.");
    DocumentFormat format = new DefaultDocumentFormatRegistry().getFormatByFileExtension(outputFormat);
    Preconditions.checkArgument(format != null, "Unknown output format.");

    this.connection = new SocketOpenOfficeConnection(host, port);
    try {
        connection.connect();
        connection.disconnect();
    } catch (Exception e) {
        throw new RuntimeException(host + ":" + port + " service not available.", e);
    }

    this.host = host;
    this.port = port;
    this.outputFormat = format;
}
 
开发者ID:FenixEdu,项目名称:oddjet,代码行数:22,代码来源:OpenOfficePrintingService.java


示例3: isValidService

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
public static boolean isValidService(String host, int port) {
    OpenOfficeConnection connection = new SocketOpenOfficeConnection(host, port);
    try {
        connection.connect();
        connection.disconnect();
    } catch (Exception e) {
        return false;
    }
    return true;
}
 
开发者ID:FenixEdu,项目名称:oddjet,代码行数:11,代码来源:OpenOfficePrintingService.java


示例4: convert

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
private void convert(
		final InputStream in,
		final DocumentFormat inputFormat,
		final OutputStream out,
		final DocumentFormat outputFormat) throws Exception {
	final String host = getPropertyHost();
	final int port = getPropertyPort();
	final OpenOfficeConnection connection = new SocketOpenOfficeConnection(host, port);
	ExecutorService executor = Executors.newSingleThreadExecutor();
	try {
		Future<String> future = executor.submit(new Callable<String>() {
			@Override
			public String call() throws Exception {
				connection.connect();
				DocumentConverter converter = new StreamOpenOfficeDocumentConverter(
						connection,
						getDocumentFormatRegistry());
				converter.convert(
						in,
						inputFormat,
						out,
						outputFormat);
				return "Ok";
		    }
		});
		if (getPropertyTimeout() != -1)
			future.get(getPropertyTimeout(), TimeUnit.SECONDS);
		else
			future.get();
	} catch (TimeoutException e) {
		throw new SistemaExternTimeoutException(
				null, 
				null, 
				null, 
				null, 
				null, 
				null, 
				null, 
				null, 
				null, 
				"(Conversió OpenOffice)", 
				e);
	} finally {
		if (connection.isConnected())
			connection.disconnect();
	}
	executor.shutdownNow();
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:49,代码来源:OpenOfficeUtils.java


示例5: main

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
/**
	 * @param args
	 * @throws ConnectException
	 */
	public static void main(String[] args) throws ConnectException {



//
		File inputFile = new File("C:\\Users\\KYJ\\Desktop\\convert\\memojava.doc");
		File outputFile = new File("C:\\Users\\KYJ\\Desktop\\convert\\memojav2.html");

		// connect to an OpenOffice.org instance running on port 8100
		OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
		connection.connect();

		// convert
		DocumentConverter converter = new OpenOfficeDocumentConverter(connection, new CustomDocFormatRegistry());
		converter.convert(inputFile, outputFile);

		// close the connection
		connection.disconnect();

	}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:25,代码来源:ConverterSampleTest.java


示例6: docToPdf

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
/**
   * 
   * @return
   * @throws ConnectException 
   */
  public boolean docToPdf(HttpServletRequest request) throws ConnectException {
  	
  	Date start = new Date();
  	/*//打开端口
  	String path = request.getSession()
		.getServletContext().getRealPath("/WEB-INF/classes/OpenOffice_Service.bat");
  	path = path.replaceFirst(" ", "\" \"");
  	System.out.println(path);
      try {
      	Process pro = Runtime.getRuntime().exec("d:\\1.bat");
	StreamGobbler errorGobbler = new StreamGobbler(pro.getErrorStream(), "Error");
	StreamGobbler outputGobbler = new StreamGobbler(pro.getInputStream(), "Iutput");
	
	errorGobbler.start();
	outputGobbler.start();
	pro.getOutputStream().close();
	
	try {
		pro.waitFor();
		pro.destroy();
		pro.exitValue();
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
} catch (IOException e) {
	// TODO Auto-generated catch block
	
	e.printStackTrace();
	return false;
}*/

      // connect to an OpenOffice.org instance running on port 8100
  	//Process pro = Runtime.getRuntime().e
      OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
      try {
          connection.connect();
          // convert
          DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
          converter.convert(inputFile, outputFile);
      } catch (ConnectException cex) {
          if (connection.isConnected()) {
              connection.disconnect();
              connection = null;
          }
          throw cex;
          
      } catch(IllegalArgumentException e){
      	throw new IllegalArgumentException("文件类型错误!上传文档格式不要高于office2003");
      }
      
      if (connection != null) {
          connection.disconnect();
          connection = null;
      }
      
      long l = (start.getTime() - new Date().getTime());
      long day = l / (24 * 60 * 60 * 1000);
      long hour = (l / (60 * 60 * 1000) - day * 24);
      long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60);
      long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
      System.out.println("生成" + outputFile.getName() + "耗费:" + min + "分" + s
              + "秒");
      return true;
  }
 
开发者ID:imalexyang,项目名称:ExamStack,代码行数:71,代码来源:JOD4DocToPDF.java


示例7: OpenOfficeConverter

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
/**
 * 默认构造函数,localhost, default port
 */
public OpenOfficeConverter() {
	this(SocketOpenOfficeConnection.DEFAULT_HOST,
			SocketOpenOfficeConnection.DEFAULT_PORT);
}
 
开发者ID:52Jolynn,项目名称:Paper2Swf,代码行数:8,代码来源:OpenOfficeConverter.java


示例8: makeObject

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
@Override
public SocketOpenOfficeConnection makeObject() throws Exception {
	return new SocketOpenOfficeConnection(host, port);
}
 
开发者ID:52Jolynn,项目名称:Paper2Swf,代码行数:5,代码来源:SocketOpenOfficeConnectionFactory.java


示例9: destroyObject

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
@Override
public void destroyObject(SocketOpenOfficeConnection conn) throws Exception {
	conn.disconnect();
}
 
开发者ID:52Jolynn,项目名称:Paper2Swf,代码行数:5,代码来源:SocketOpenOfficeConnectionFactory.java


示例10: validateObject

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; //导入依赖的package包/类
@Override
public boolean validateObject(SocketOpenOfficeConnection conn) {
	return conn.isConnected();
}
 
开发者ID:52Jolynn,项目名称:Paper2Swf,代码行数:5,代码来源:SocketOpenOfficeConnectionFactory.java



注:本文中的com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java User类代码示例发布时间:2022-05-22
下一篇:
Java SerializerFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap