HttpURLConnection:
URL url = new URL("http://example.com");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int code = connection.getResponseCode();
This is by no means a robust example; you'll need to handle IOException
s and whatnot. But it should get you started.
If you need something with more capability, check out HttpClient.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…