如何分解合成mht文件

wd9053 2009-12-22 10:22:09
如题,请问Java如何将mht文件分离为html文件和图片文件夹,如何将html文件和图片文件夹转换为mht文件。
求思路或实现代码。
...全文
345 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
一头头 2009-12-22
  • 打赏
  • 举报
回复

import com.chilkatsoft.CkMht;
import com.chilkatsoft.CkString;

public class HtmlToMht {

static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}

public static void main(String argv[])
{
// Create a MHT object...
CkMht mht = new CkMht();
mht.UnlockComponent("anything for 30-day trial");

String html = "<html><body><img src=\"http://www.chilkatsoft.com/images/dude.gif\"><br>Chilkat Software Inc</body></html>";
CkString strMht = new CkString();
boolean success = mht.HtmlToMHT(html,strMht);
if (!success)
{
mht.SaveLastError("lastError.txt");
}
else
{
// Save the string to a file...
strMht.saveToFile("output/dude.mht","windows-1252");

// To access the MHT string, do this:
String mhtString = strMht.getString();
}

}
}

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧