下载此文档

Java指定编码生成静态网页技术.doc


文档分类:IT计算机 | 页数:约6页 举报非法文档有奖
1/6
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/6 下载此文档
文档列表 文档介绍
import ;
import ;
import ;
import ;
import .HttpURLConnection;
import .URL;
public class HtmlPage {

public static void main(String[] args) {
// TODO Auto-generated method stub
if(saveHtmlPage( getHtmlPage("","UTF-
8"),"F:/")){
("生成成功");
}else{
("生成失败");
}

if(deleteFile("F:/")){
("删除成功");
}else{
("删除失败");
}

}

/**
*
* ***@param httpURL 网页地址
*
* ***@param encode 默认为UTF-8
* ***@return Html 页面的代码
*/
public static String getHtmlPage(String httpURL,String encoding){

String htmlCode="";

try {
InputStream inputStream;
URL url = new URL(httpURL);
HttpURLConnection connection = (HttpURLConnection) ();
();

inputStream = ();
byte bytes[] = new byte[1024 * 2000];
int index = 0;
int count = (bytes, index, 1024 * 2000);
while (count != -1) {
index += count;
count = (bytes, index, 1);
}
htmlCode = new String(bytes, encoding);
// htmlCode = new String(bytes);
();
} catch (Exception ex) {
();
return null;
}
return ();

}

public static boolean saveHtmlPage(String htmlCode,String fileName

Java指定编码生成静态网页技术 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数6
  • 收藏数0 收藏
  • 顶次数0
  • 上传人mh900965
  • 文件大小35 KB
  • 时间2018-01-12