voila mon foction:
L'execption qui s'affiche sur le console est:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
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 public StringBuffer getURLContent(String link)//link est l'adressedu page web { sb = new StringBuffer(); len = new ArrayList(); lineCount = 0; try { URL url = new URL(link); BufferedReader in = new BufferedReader(new InputStreamReader( url.openStream())); String line; while ((line = in.readLine()) != null) { sb.append(line + "\n"); len.add(new Integer(sb.length())); lineCount++; } in.close(); return sb; } catch(IOException e) { System.err.println(e.toString()); } return sb; }
http://www.google.com/java.net.UnknownHostException: www.google.com
Partager