Equivalent of .NET's WebClient and HttpWebRequest in Java?
问题 .NET has the HttpWebRequest and WebClient classes for simulating a browser's requests. I'd google it, but I'm not sure what keyword to use. 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. 回答1: HttpURLConnection is Java's equivalent of HttpWebRequest . URL iurl = new URL(url); HttpURLConnection uc = (HttpURLConnection)iurl.openConnection(); uc.connect(); if