本文介绍了在Java中等效于.NET的WebClient和HttpWebRequest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! .NET具有 HttpWebRequest 和 WebClient 类,用于模拟浏览器的.NET has the HttpWebRequest and WebClient classes for simulating a browser's requests.我会用Google搜索它,但不确定使用哪个关键字。I'd google it, but I'm not sure what keyword to use. I想要编写在applet或本地 .jar 中执行HTTP GET和POST以及Cookie的代码,并以文本字符串或其他可解析的形式返回响应结构。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.推荐答案 HttpURLConnection 是Java的 HttpWebRequest 。URL iurl = new URL(url);HttpURLConnection uc = (HttpURLConnection)iurl.openConnection();uc.connect();if (uc.getContentType().equalsIgnoreCase("image/jpeg")){ result = true;} 这篇关于在Java中等效于.NET的WebClient和HttpWebRequest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-06 09:11