Skip to content

Commit

Permalink
import commons-io
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jan 8, 2013
1 parent cef2666 commit 09536d8
Showing 1 changed file with 16 additions and 2 deletions.
@@ -1,7 +1,6 @@
package org.jumpmind.util;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -99,13 +98,28 @@ public static <T,U> T[] copyOfRange(U[] original, int from, int to, Class<? exte

public static <T> T[] add(T[] one, T[] two) {
int size = one.length + two.length;
T[] copy = Arrays.copyOf(one, size);
T[] copy = copyOf(one, size);
for (int i = one.length; i < size; i++) {
copy[i] = two[i-one.length];
}
return copy;
}

@SuppressWarnings("unchecked")
public static <T> T[] copyOf(T[] original, int newLength) {
return (T[]) copyOf(original, newLength, original.getClass());
}

@SuppressWarnings("unchecked")
public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
T[] copy = ((Object)newType == (Object)Object[].class)
? (T[]) new Object[newLength]
: (T[]) Array.newInstance(newType.getComponentType(), newLength);
System.arraycopy(original, 0, copy, 0,
Math.min(original.length, newLength));
return copy;
}

public static String toCommaSeparatedValues(Collection<?> list) {
StringBuilder csv = new StringBuilder();
if (list != null) {
Expand Down

0 comments on commit 09536d8

Please sign in to comment.