Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;

public class Main {
    /**
     * 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]);
    }
}