Skip to content

Instantly share code, notes, and snippets.

@aembleton
Created October 23, 2013 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aembleton/7116697 to your computer and use it in GitHub Desktop.
Save aembleton/7116697 to your computer and use it in GitHub Desktop.
package uk.transactis.csvParsing.util;
public class ArrayUtil {
/**
* Trims all elements of an array without side affect.
*
* @param array
* Array from which to base the output array
* @return A new array that equals input array but with each element
* trimmed.
*/
public static String[] trimArray(String[] array) {
String[] trimmedArray = new String[array.length];
for (int i = 0; i < array.length; i++) {
trimmedArray[i] = array[i].trim();
}
return trimmedArray;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment