Here you can find the source of parseArgs(String[] args)
Parameter | Description |
---|---|
args | the arguments to be parsed. |
public static String[] parseArgs(String[] args)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w . j a va2 s. c o m*/ * Parses the command line arguments. * * @param args the arguments to be parsed. * @return a string with the values of the arguments. */ public static String[] parseArgs(String[] args) { List<String> col = new ArrayList<String>(); for (String arg : args) { String narg = arg.trim(); if (narg.contains("=")) { for (String n : narg.split("=")) { col.add(n); } } else col.add(arg.trim()); } boolean sproject = false; boolean sfile = false; boolean sproperties = false; boolean srepr = false; String project = ""; String file = ""; String properties = ""; String repr = ""; for (String c : col) { if (c.startsWith("-project")) { sproject = true; sfile = false; sproperties = false; srepr = false; } else if (c.startsWith("-file")) { sproject = false; sfile = true; sproperties = false; srepr = false; } else if (c.startsWith("-properties")) { sproject = false; sfile = false; sproperties = true; srepr = false; } else if (c.startsWith("-repr")) { sproject = false; sfile = false; sproperties = false; srepr = true; } else { if (sproject) project += c + " "; else if (sfile) file += c + " "; else if (sproperties) properties += c + " "; else if (srepr) repr += c + " "; } } return new String[] { project.trim(), file.trim(), properties.trim(), repr.trim().toUpperCase() }; } }