Java List Trim trimList(List source)

Here you can find the source of trimList(List source)

Description

Trims all items in a list of strings.

License

Open Source License

Parameter

Parameter Description
source The strings to be converted

Return

The converted strings

Declaration

public static List<String> trimList(List<String> source) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from   ww w.j a  v a 2s .c  o  m*/
     * Trims all items in a list of strings. A string that starts with a
     * single backslash has that backslash removed.
     * @param source The strings to be converted
     * @return The converted strings
     */
    public static List<String> trimList(List<String> source) {

        List<String> result = new ArrayList<String>(source.size());

        for (int i = 0; i < source.size(); i++) {
            String trimmedValue = source.get(i).trim();
            if (trimmedValue.startsWith("\\")) {
                trimmedValue = trimmedValue.substring(1);
            }

            result.add(trimmedValue);
        }

        return result;
    }
}

Related

  1. trimEndDigital(List strs)
  2. trimIfLastIndex(List suggestedList, String suggestedWords, int i)
  3. trimKeyFormat(String s3KeyFormat, List disallowedKeys)
  4. trimLeadingWhitespaces(List lines)
  5. trimList(List list)
  6. trimListValues(List original)
  7. trimSequence(int m, List sequence)
  8. trimStringLineList(List lines)
  9. trimStrings(List list)