String inputFile = null; String outputFile = null; String host = "localhost"; int port = 80; boolean launch = false; for (int i = 0; i < args.length; i++) { String x = args[i]; if (x.startsWith("-h")) { if (x.length() > 2) host = x.substring(2); else host = args[++i]; } else if (x.startsWith("-p")) { if (x.length() > 2) port = Integer.parseInt(x.substring(2)); else port = Integer.parseInt(host = args[++i]); } else if (x.startsWith("-o")) { if (x.length() > 2) outputFile = x.substring(2); else outputFile = args[++i]; } else if (x.startsWith("-a")) launch = true; else inputFile = args[i]; }