该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
如下面这个,就是生成htm文件的
========
第一步:下载chm4j.jar
第二步:新建java工程,建一个解析ParseChm类,建一个解析测试类,类似:
ParseChm类:
//下面的包,请导入chm4j.jar,并且把chm4j.dll拷贝到jre的lib目录内,linux或mac请拷贝libchm4j.so即//可,因为chm4j.jar依赖于c++
packagecn.lswe.baseframe.utils;
importjava.io.File;
importjava.io.FileOutputStream;importjava.io.IOException;importjava.io.InputStream;importjava.io.OutputStream;
importorg.chm4j.*;
importcn.lswe.baseframe.validator.Conf;
publicclassParseChm{
publicstaticvoidmain(String...args){
try{
ChmFilecFile=newChmFile(Conf.ChmSOurce);Stringdir=Conf.dir;
ChmEntry.Attributeattributes=ChmEntry.Attribute.ALL;ChmEntry[]entries=cFile.entries(attributes);
for(ChmEntryentry:entries){listChmEntry(dir,entry,attributes);
}
}catch(IOExceptionex){
System.out.println("Error:"+ex.getMessage());
}
}
/**
*ExtractsrecursivelythesubentriesofthespecifiedChmEntryintothe
*specifiedoutputdirectoryaccordingtothespecifiedattributes.
*@paramoutputTheoutputdirectory.
*@paramentry
*@paramattributes
*@throwsjava.io.IOExceptionIfanI/Oerroroccurs.
*/
privatestaticvoidlistChmEntry(Stringoutput,ChmEntryentry,ChmEntry.Attributeattributes)throwsIOException{
printEntry(entry);
Stringer=GuidHelper.CreateGuid().toString();Filedest=newFile(output,entry.getPath());
if(entry.hasAttribute(ChmEntry.Attribute.DIRECTORY)){if(!dest.isDirectory()){
if(!dest.mkdirs()){
thrownewIOException("failedtocreatedirectory:"+dest);
}
}
for(ChmEntrye:entry.entries(attributes)){listChmEntry(output,e,attributes);
}
}else{
InputStreamin=null;OutputStreamout=null;try{
in=entry.getInputStream();
out=newFileOutputStream(dest);intbufferSize=1024;
byte[]data=newbyte[bufferSize];intnbRead;