(急)如何在java中显示html的内容? 显示文本内容,直接用FileInputStream读取,然后显示在JTextArea()就行了。显示网页内容,用JEditorPane,相当于一个小型浏览器! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看javax.swing.text.html 这个包下面的冬冬 我是这么写的,不过url老是出错,为什么? URL url = null; String path = null; try { path = "C:/readme.htm"; url = getClass().getResource(path); } catch (Exception e) { System.err.println("Failed to open " + path); url = null; } if(url != null) htmlPane.setPage(url); } 不明白你是不是要读取html文本吗?我这里倒是有一个。urlsource 为http地址。filename为保存文件名。public void fsave(String urlsource,File filename) { netsocket=true; try { URL url = new URL(urlsource); HttpURLConnection urlConn= (HttpURLConnection)url.openConnection(); InputStream in=url.openStream(); if (urlConn.getResponseMessage().equals("OK")) { int b; int bt=0; FileOutputStream cf = new FileOutputStream(filename); while ((b=in.read())!=-1 && bt<=100000) { cf.write(b); bt++; } cf.close(); writeLog("总字节数为:"+bt); } in.close(); } catch (IOException exception) { writeLog("fsave file Error: " + exception); netsocket=false; } }如果是要用java做IE浏览器似的冬冬,我就不懂了。 JMF如何使用 谁能去除Frame窗体的最大化\最小化\关闭按钮 100分求java科学计算器 在jdk下面调用com出问题拉?劳驾知道的进来一下。 给个地址,人家翻译的还可以,尊重他人的劳动成果!!!! 请教一道英文题 动态Table 怎样做?请各位进来看看,等待 谁有类似bugbase的工具,用于公司内部开发测试的交流协调。 英雄在哪儿?一个关于weblogic的小问题!60分! java问题??? 初始化错误! 我的JB编译用j2sdk1.4时为什么出错?
URL url = null;
String path = null;
try {
path = "C:/readme.htm";
url = getClass().getResource(path);
} catch (Exception e) {
System.err.println("Failed to open " + path);
url = null;
}
if(url != null)
htmlPane.setPage(url); }
urlsource 为http地址。filename为保存文件名。
public void fsave(String urlsource,File filename)
{ netsocket=true;
try
{
URL url = new URL(urlsource);
HttpURLConnection urlConn= (HttpURLConnection)url.openConnection();
InputStream in=url.openStream();
if (urlConn.getResponseMessage().equals("OK"))
{
int b;
int bt=0;
FileOutputStream cf = new FileOutputStream(filename);
while ((b=in.read())!=-1 && bt<=100000)
{ cf.write(b);
bt++;
}
cf.close();
writeLog("总字节数为:"+bt);
}
in.close();
}
catch (IOException exception)
{ writeLog("fsave file Error: " + exception);
netsocket=false;
}
}
如果是要用java做IE浏览器似的冬冬,我就不懂了。