1 // TODO:把网页中的链接替换为本地路径及文件名
2 for (String link : links) {
3 String baseLink = "http://localhost:91/qywz/template3/";
4 String realLink = link.replace(baseLink, "");
5 System.out.println("realLink=========="+realLink);
6 //转化为本地链接规则
7 String localLink ="";
8 localLink=getFileNameByUrl(link,
9 getMethod.getResponseHeader("Content-Type")
10 .getValue());
11 System.out.println("localLink=========="+localLink);
12 //替换
13 htmlStr=htmlStr.replace("\""+realLink+"\"","\""+localLink+"\"");
14 htmlStr=htmlStr.replace("'"+realLink+"'","'"+localLink+"'");
15 System.out.println("本页面链接=========="+link);
16 //System.out.println("页面内容=========="+htmlStr);
17 }