java实现发送http请求:
public static String send_url(String urlStr) {
BufferedReader reader = null;
try {
URL url = new Url(urlStr);
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
InputStream in = conn.getInputStream();
reader = new BufferedReader(new InputStreamReader(in));
String line = reader.readLine();
System.out.println(line);
} catch(IOException e) {
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}