Here you can find the source of trimStringArray(final String[] input)
Parameter | Description |
---|---|
input | The array of strings to be trimmed |
public static String[] trimStringArray(final String[] input)
//package com.java2s; import java.util.ArrayList; public class Main { /**// ww w . j a va2s . com * Trims an array of Strings to remove the whitespace. If the string is empty then its removed from the array. * * @param input The array of strings to be trimmed * @return The same array of strings but all elements have been trimmed of whitespace */ public static String[] trimStringArray(final String[] input) { final ArrayList<String> output = new ArrayList<String>(); for (int i = 0; i < input.length; i++) { String s = input[i].trim(); if (!s.equals("")) output.add(s); } return output.toArray(new String[0]); } }