diff --git a/HttpReq.java b/HttpReq.java new file mode 100644 index 0000000..7120daf --- /dev/null +++ b/HttpReq.java @@ -0,0 +1,76 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; + +public class HttpReq { + + private static final String URLstr="http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q="; + + private static void sendReq(String title) throws IOException{ + URL obj=new URL(URLstr+title); + HttpURLConnection con=(HttpURLConnection)obj.openConnection(); + con.setRequestMethod("GET"); + int responseCode = con.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { // success + BufferedReader in = new BufferedReader(new InputStreamReader( + con.getInputStream())); + String inputLine; + StringBuffer response = new StringBuffer(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + String str = null; + boolean record=false; + for(int i=0;i