I needed a way to issue an HTTPRequest in Java, and I don’t care about the return value. I wasn’t able to find a simple example so I thought I’d post my that part of my solution. I don’t know that it’s the best way, but it works.
import java.net.URL; public class Request { public static void main(String[] args) throws Exception { if(args.length == 0) { System.out.println("URL required."); return; } URL url = new URL(args[0]); url.openStream().close(); } }
And to use it you just pass in the url via the command line
java Request http://joezack.com