Here you can find the source of getWithoutEmptyParams(String[] cmdarray)
private static String[] getWithoutEmptyParams(String[] cmdarray)
//package com.java2s; /****************************************************************************** * Copyright (C) 2013 Fabio Zadrozny//from w ww .j a va2 s. c o m * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Fabio Zadrozny <fabiofz@gmail.com> - initial API and implementation ******************************************************************************/ import java.util.ArrayList; public class Main { /** * @return a new array without any null/empty elements originally contained in the array. */ private static String[] getWithoutEmptyParams(String[] cmdarray) { if (cmdarray == null) { return null; } ArrayList<String> list = new ArrayList<String>(); for (String string : cmdarray) { if (string != null && string.length() > 0) { list.add(string); } } return list.toArray(new String[list.size()]); } }