C#通过http协议

   StreamReader din = File.OpenText("url_ys.txt");               

              str = din.ReadLine();
                din.Close();

                // 设置打开页面的参数
                String url = http://127.0.0.1:8060/myjob;
                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                request.Method = "GET";
                request.KeepAlive = false;
                request.Timeout = 5000;

                // 接收返回的页面
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                System.IO.Stream responseStream = response.GetResponseStream();
                System.IO.StreamReader reader = new System.IO.StreamReader(responseStream, Encoding.Default);
                String srcString = reader.ReadToEnd();

 

                reader.Close();
                response.Close();

                UI ui = new UI(srcString);

                reader.Close();
                response.Close();

你可能感兴趣的:(java,http,C#)