Here you can find the source of getTrimmedList(List
Parameter | Description |
---|---|
listA | the list a |
public static List<String> getTrimmedList(List<String> listA)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { /**/*from w ww . j a v a 2s . c o m*/ * Gets the trimmed list. * * @param listA * the list a * @return the trimmed list */ public static List<String> getTrimmedList(List<String> listA) { ArrayList<String> newAList = new ArrayList<String>(); if ((listA != null) && (listA.size() > 0)) { for (String aStr : listA) { String val = trimToNull(aStr); if (null != val) { newAList.add(val); } } } return newAList; } /** * Trim to null. * * @param value * the value * @return the string */ private static String trimToNull(String value) { if (null != value) { value = value.replaceAll("[\r\n]", ""); value = value.equals("") ? null : value.trim(); } return value; } }