Java Array Trim trim(String[] data)

Here you can find the source of trim(String[] data)

Description

trim

License

Apache License

Declaration

static String[] trim(String[] data) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    static String[] trim(String[] data) {
        List<String> result = new ArrayList<String>();
        for (String val : data) {
            String trimmed = val.trim();
            if (!trimmed.isEmpty()) {
                result.add(trimmed);/*from  w  w w .j  av a2 s  .c o  m*/
            }
        }
        return result.toArray(new String[] {});
    }
}

Related

  1. trim(byte[] src, byte padding, boolean right, int minLength)
  2. trim(String s, char delimit[])
  3. trim(String[] args)
  4. trim(String[] array)
  5. trim(String[] array)
  6. trim(String[] s)
  7. trim(String[] strings)
  8. trimArray(char[] buffer, int read)
  9. trimArray(final byte[] seq, final int trimFromFront, final int trimFromBack)