java发送http请求——最简洁版

try {
			URL url = new URL("http://localhost/SameTimeApp/DownloadDatServlet");
			HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
			httpURLConnection.setRequestMethod("GET");
			httpURLConnection.setDoOutput(true);
			httpURLConnection.getInputStream();
		} catch (Exception e1) {
			e1.printStackTrace();
		}


主要是用到URL这个class
详见: http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html

你可能感兴趣的:(java,html,.net,J2SE,sun)