Java Utililty Methods List Trim

List of utility methods to do List Trim

Description

The list of methods to do List Trim are organized into topic(s).

Method

ListtrimList(List source)
Trims all items in a list of strings.
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;
ListtrimListValues(List original)
Trims all values in a list of strings
List<String> trimmedList = new ArrayList<String>();
for (int i = 0; i < original.size(); i++)
    trimmedList.add((original.get(i).toString()).trim());
return trimmedList;
ListtrimSequence(int m, List sequence)
trim Sequence
List<String> result = new ArrayList<String>();
for (int i = sequence.size() - 1; result.size() < m; i--) {
    result.add(0, sequence.get(i));
assert result.size() == m;
assert result.get(result.size() - 1).equals(sequence.get(sequence.size() - 1));
return result;
ListtrimStringLineList(List lines)
Trims a List of String lines.
List<String> newLines = new ArrayList<String>();
if (lines != null) {
    for (String line : lines) {
        String str = line;
        str = line.trim();
        String newLine = str;
        newLines.add(newLine);
return newLines;
ListtrimStrings(List list)
Trim all strings in a List.
if (list == null)
    return null;
int sz = list.size();
for (int i = 0; i < sz; i++)
    list.set(i, nullTrim((String) list.get(i)));
return list;
ListtrimStringToNewList(List list, Boolean isLower)
trim String To New List
List<String> temp = new ArrayList<>();
String str = null;
for (int i = 0; i < list.size(); i++) {
    temp.add(isLower ? list.get(i).trim().toLowerCase() : list.get(i).trim());
return temp;
ListtrimSuffix(List strs)
trim Suffix
String endStr = strs.get(strs.size() - 1);
if (SUFFIXES.contains(endStr)) {
    strs.remove(strs.size() - 1);
return strs;
ListtrimToList(String importOrder1)
trim To List
ArrayList<String> strings = new ArrayList<String>();
String[] split = importOrder1.split(";");
for (String s : split) {
    String trim = s.trim();
    if (!trim.isEmpty()) {
        strings.add(trim);
return strings;
voidtrimToSize(List listToTrim, int size)
trim To Size
listToTrim.subList(size, listToTrim.size()).clear();