import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection;
URLConetent public class { public static void main (String [] args) {
URL url;
try {
// get URL content
String a="http://localhost:8080//TestWeb/index.jsp";
url = new URL(a);
URLConnection conn = url.openConnection();
// open the stream and put it into BufferedReader
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
while ((inputLine = br.readLine()) != null) {
System.out.println(inputLine);
}
br.close();
System.out.println("Done");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
* Mise à jour *. Citation de la page d'accueil HttpClient d'Apache Commons: "Le projet Commons HttpClient est maintenant en fin de vie, et n'est plus en cours de développement. ** Il a été remplacé ** par [Apache HttpComponents] (http: //hc.apache. org /) dans ses modules [HttpClient] (http://hc.apache.org/httpcomponents-client-ga) et [HttpCore] (http://hc.apache.org/httpcomponents-core-ga/), qui offrent de meilleures performances et plus de flexibilité. " – informatik01