Here you can find the source of addMultiLine(String multiLine, List
Parameter | Description |
---|---|
multiLine | a string. |
commandsList | a list of strings. |
public static void addMultiLine(String multiLine, List<String> commandsList)
//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); } } } } }