Here you can find the source of truncateStringList(List
Parameter | Description |
---|---|
strings | list of strings to truncate |
truncateFrom | a parameter |
static public List<String> truncateStringList(List<String> strings, String truncateFrom)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 ARM Ltd. and others * 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:// w ww . j a va 2 s . c o m * ARM Ltd and ARM Germany GmbH - Initial API and implementation *******************************************************************************/ import java.util.List; public class Main { /** * Removes all entries in the list after truncateFrom string (inclusive truncateFrom entry) * @param strings list of strings to truncate * @param truncateFrom * @return updated list */ static public List<String> truncateStringList(List<String> strings, String truncateFrom) { if (strings == null) return null; int index = strings.indexOf(truncateFrom); if (index >= 0) return strings.subList(0, index); return strings; } }