javahttpclient:Java版HttpClient来源: 发布时间:星期四, 2009年2月12日 浏览:85次 评论:0
/** * This is a test program for HttpClient. @author Hu Dennis created at 2008-11-12 */ import java.net.Socket; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; public ![]() public ![]() ![]() ![]() String dstHost = "10.56.135.64"; ![]() Socket clientSocket = null; DataOutputStream outBound = null; DataInputStream inBound = null; try { clientSocket = ![]() clientSocket. ![]() outBound = ![]() ![]() inBound = ![]() ![]() StringBuilder request = ![]() ![]() request.append("GET /test.html HTTP/1.1\n"); request.append("HOST:10.56.135.64\n\r\n"); outBound.writeBytes(request.toString ![]() BufferedReader bfReader = ![]() ![]() String responseLine = null; while ((responseLine = bfReader.readLine ![]() ![]() ![]() ![]() ![]() } outBound.close ![]() inBound.close ![]() clientSocket.close ![]() } catch (IOException e) { ![]() ![]() } ![]() ![]() } } 0
相关文章读者评论发表评论 |