Bonjour,

Je souhaite utiliser HttpClient pour me connecter à une page web.

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
public String test() throws ClientProtocolException, IOException
		{
			HttpClient httpclient = new DefaultHttpClient();
			HttpGet httpget = new HttpGet("http://localhost/");
			HttpResponse response = httpclient.execute(httpget);
			HttpEntity entity = response.getEntity();
			if (entity != null) {
			    InputStream instream = entity.getContent();
			    byte[] tmp = new byte[2048];
			    while ((instream.read(tmp)) != -1) {
			    }
			}
 
			return null;
		}
Mais quand je test ce code j'obtiens l'erreur suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
Exception in thread "main" java.lang.RuntimeException: Stub!
	at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:5)
	at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:7)
	at metier.Connection.test(Connection.java:165)
Merci de votre aide.