Send HTTP request & fetching data using Java

Submitted by:Jhon Jhon

Date added:03 July, 2013

Category:Java

Java code example showing here how to send HTTP request & fetching data

Tags: http request , fetching data

Code Snippet:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

public class Main {
public static void main(String[] args) {
try {
URL my_url = new URL("http://www.mywebsite.com/");
BufferedReader br = new BufferedReader(new InputStreamReader(my_url.openStream()));
String strTemp = "";
while(null != (strTemp = br.readLine())){
System.out.println(strTemp);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
 
 

Comments