Bonjour,
Je n'arrive pas à accéder au code source d'une page web, celle ci est accessible en utilisant un navigateur internet mais pas à partir de mon application Java. Je suis sous Windows Server 2003 R2 et voici mon code:
Mon exception apparait à la ligne :
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 public static void getModels() { BufferedReader br = null; try { URL geturl = new URL("http://www.google.fr"); URLConnection yc = geturl.openConnection(); yc.setConnectTimeout(1000); br = new BufferedReader(new InputStreamReader(yc.getInputStream())); String inputLine = ""; int j = 0; String[] infos = { "", "", "", "" }; //Check all lines to retrieve information while ((inputLine = br.readLine()) != null && j!= 4) { System.out.println(inputLine); } } catch (Exception e) { System.err.println("Error during the getModels command : " + e + "\n"); } finally { if (br != null) {try {br.close();} catch (IOException e) {e.printStackTrace();} } } }
A premiere vue je dirais le parfeu... Qu'en pensez vous ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part br = new BufferedReader(new InputStreamReader(yc.getInputStream()));
Merci pour votre aide
EDIT : Message d'erreur
Error during the getModels command : java.net.SocketTimeoutException: connect timed out
Partager