java打开html文件

你的意思是用java代码模拟访问一个html网页? 可以用URLConnection URL url = new URL("你的html文件的http地址");URLConnection URLconnection = url.openConnection();HttpURLConnection httpConnection = (HttpURLConnection) URLconnection;InputStream urlStream = httpConnection.getInputStream();另外...
java打开html文件
你的意思是用java代码模拟访问一个html网页? 可以用URLConnection
URL url = new URL("你的html文件的http地址");
URLConnection URLconnection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) URLconnection;
InputStream urlStream = httpConnection.getInputStream();

另外如果html里有js的话 是不能模拟访问js的2010-06-13
java swing中有个简单的浏览器组件,由于html标准的不统一,导致html解析相当复杂,你如果想自己开发的话,我建议你不要这么干2010-06-12
OutputStream outstream = null;

outstream = openFileOutput(fileName ,MODE_WORLD_READABLE);

if (outstream != null) {

OutputStreamWriter outputreader = new OutputStreamWriter(outstream);
BufferedWriter buffwriter = new BufferedWriter(outputreader);

buffwriter.write(result);

}

outstream.close();

} catch (java.io.FileNotFoundException e) {
System.out.println("File not found in the writing...");
} catch (IOException e) {
System.out.println("In the writing...");
}

然后又回调文件:
fileView.getSettings().setJavaScriptEnabled(true);
fileView.loadUrl("file:///" + name); <---

然后程序中我就获得错误提示说不能找到这个文件。2015-11-21
JEditorPane可以显示HTML2010-06-12
mengvlog 阅读 207 次 更新于 2025-10-30 15:59:25 我来答关注问题0
檬味博客在线解答立即免费咨询

代码相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部