Thursday, August 2, 2012

send a HTTP Get request by Java


URL stageds2k7 = new URL("http://xxx.stg.yyy.com/ds2k7/services");
URLConnection sc = stageds2k7.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(sc.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
               content.append(inputLine);
// System.out.println(inputLine);
}
in.close();

No comments:

Post a Comment