Here you can find the source of removeFlag(String[] options, String flag)
Parameter | Description |
---|---|
options | the options to check |
flag | the flag to look for (incl. "-") |
public static boolean removeFlag(String[] options, String flag)
//package com.java2s; /*// w ww . ja v a 2s .c om * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.List; public class Main { /** * Checks whether the flag is in the option string and removes the flag * if present. * * @param options the options to check * @param flag the flag to look for (incl. "-") * @return true if a help flag is among the options */ public static boolean removeFlag(String[] options, String flag) { boolean result; int i; result = false; for (i = 0; i < options.length; i++) { if (options[i].equals(flag)) { options[i] = ""; result = true; break; } } return result; } /** * Checks whether the flag is in the option string and removes the flag * if present. * * @param options the options to check * @param flag the flag to look for (incl. "-") * @return true if a help flag is among the options */ public static boolean removeFlag(List<String> options, String flag) { boolean result; int i; result = false; for (i = 0; i < options.size(); i++) { if (options.get(i).equals(flag)) { options.set(i, ""); result = true; break; } } return result; } }