使用java代码打开chm格式的帮助文档

 
  

package com.guan.code20160405;

import java.io.File;
import java.io.IOException;

public class OpenHelpFile {

public static void main(String[] args) {

/**

*我把五子棋文档1.0.chm放在和项目同目录下的projectFile文件夹下

*/
String ch1="/";
String ch2="//";
//找到项目的根路径
String contextPath = System.getProperty("user.dir");
File file=new File(contextPath);
String p = file.getParent();
file = new File(p + "/projectFile");
System.out.println("path===="+file.getPath());
System.out.println("parent==="+file.getParent());
String helpFilePath = p + "/projectFile/五子棋文档1.0.chm";
try {

//hh.exe是Windows系统中允许chm文件的程序
Runtime.getRuntime().exec("hh.exe "+helpFilePath.replaceAll(ch1,ch2));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}

运行,成功打开“五子棋文档1.0.chm”文件。

转载于:https://www.cnblogs.com/gwq369/p/5358091.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值