1
public String getOneHtml(String htmlurl, String bianma) throws IOException {
2
URL url;
3
String temp;
4
final StringBuffer sb = new StringBuffer();
5
StringBuffer sb2 = new StringBuffer();
6
//因為htmlurl字符串中如果出現(xiàn)空白的字符就會出異常
7
String [] htmlurls=htmlurl.split(" ");
8
for (int i = 0; i < htmlurls.length; i++) {
9
if ("".equals(htmlurls[i])) {
10
continue;
11
}
12
sb2.append(htmlurls[i]);
13
}
14
try {
15
url = new URL(sb2.toString());
16
final BufferedReader in = new BufferedReader(new InputStreamReader(
17
url.openStream(), bianma));
18
while ((temp = in.readLine()) != null) {
19
sb.append(temp);
20
}
21
in.close();
22
} catch (final MalformedURLException me) {
23
// System.out.println("the url is error");
24
me.getMessage();
25
throw me;
26
} catch (final IOException e) {
27
e.printStackTrace();
28
throw e;
29
}
30
return sb.toString();
31
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31
