Java Comma Separated List addMultiLine(String multiLine, List commandsList)

Here you can find the source of addMultiLine(String multiLine, List commandsList)

Description

Split a string into separate lines and add them to the list.

License

Open Source License

Parameter

Parameter Description
multiLine a string.
commandsList a list of strings.

Declaration

public static void addMultiLine(String multiLine, List<String> commandsList) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Liviu Ionescu./* w ww.j  ava2 s. co  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:
 *     Liviu Ionescu - initial version
 *******************************************************************************/

import java.util.List;

public class Main {
    /**
     * Split a string into separate lines and add them to the list.
     * 
     * @param multiLine
     *            a string.
     * @param commandsList
     *            a list of strings.
     */
    public static void addMultiLine(String multiLine, List<String> commandsList) {

        if (!multiLine.isEmpty()) {
            String[] commandsStr = multiLine.split("\\r?\\n"); //$NON-NLS-1$
            for (String str : commandsStr) {
                str = str.trim();
                if (str.length() > 0) {
                    commandsList.add(str);
                }
            }
        }
    }
}

Related

  1. addExecutableForBatchFile(List command)
  2. addItemFromCommaStrings(final List list, final String commaStrings)
  3. addJvmArgumentsAndOptions(final List commandLine, final String[] jvmArgsOpts)
  4. addPropertyToCommand(List command, String key, String value)
  5. commaDelimitedListToStringArray(final String str)
  6. commaDelimitedListToStringArray(String str)
  7. commaDelimitedListToStringArray(String str)