本文介绍了.NET的Web客户端的Equivallent和HttpWebRequest的在Java中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET有 HttpWebRequest的和的用于模拟浏览器的请求。

.NET has HttpWebRequest and WebClient for simulating a browser's requests.

我想谷歌,但我不知道该用什么关键字。

I'd google it, but I'm not sure what keyword to use.

我想写code,它确实HTTP GET和POST,还有饼干,在一个applet或当地的罐子,让我回到了一个文本字符串或其他可分析的结构响应。

I want to write code that does does HTTP GETs and POSTs, along with cookies, in an applet or local jar and gives me back the response in a text string or some other parseable structure.

推荐答案

<$c$c>HttpURLConnection就是Java中的等价物的HttpWebRequest

URL iurl = new URL(url);
HttpURLConnection uc = (HttpURLConnection)iurl.openConnection();
uc.connect();
if (uc.getContentType().equalsIgnoreCase("image/jpeg"))
{
  result = true;
}

这篇关于.NET的Web客户端的Equivallent和HttpWebRequest的在Java中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 21:05