要执行HTTP PUT:
URL url = new URL("http://www.example.com/resource");HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();httpCon.setDoOutput(true);httpCon.setRequestMethod("PUT");OutputStreamWriter out = new OutputStreamWriter( httpCon.getOutputStream());out.write("Resource content");out.close();httpCon.getInputStream();
要执行HTTP删除:
URL url = new URL("http://www.example.com/resource");HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();httpCon.setDoOutput(true);httpCon.setRequestProperty( "Content-Type", "application/x-www-form-urlenpred" );httpCon.setRequestMethod("DELETE");httpCon.connect();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)