900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > java语法 chm_使用java代码打开chm格式的帮助文档

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

时间:2023-04-29 21:32:53

相关推荐

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

package com.guan.code0405;

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();

}

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。