public static String[] toStringArray(Object value){
  if (value == null) {
    return new String[0];
  }
  Class<?> type=value.getClass();
  if (type.isArray() == false) {
    return new String[]{value.toString()};
  }
  Class componentType=type.getComponentType();
  if (componentType.isPrimitive()) {
    if (componentType == int.class) {
      return ArraysUtil.toStringArray((int[])value);
    }
 else     if (componentType == long.class) {
      return ArraysUtil.toStringArray((long[])value);
    }
 else     if (componentType == double.class) {
      return ArraysUtil.toStringArray((double[])value);
    }
 else     if (componentType == float.class) {
      return ArraysUtil.toStringArray((float[])value);
    }
 else     if (componentType == boolean.class) {
      return ArraysUtil.toStringArray((boolean[])value);
    }
 else     if (componentType == short.class) {
      return ArraysUtil.toStringArray((short[])value);
    }
 else     if (componentType == byte.class) {
      return ArraysUtil.toStringArray((byte[])value);
    }
 else {
      throw new IllegalArgumentException();
    }
  }
 else {
    return ArraysUtil.toStringArray((Object[])value);
  }
}

public static String [ ] toStringArray ( Object value ) { if ( value == null ) { return new String [ 0 ] ; } Class < ? > type = value . getClass ( ) ; if ( type . isArray ( ) == false ) { return new String [ ] { value . toString ( ) } ; } Class componentType = type . getComponentType ( ) ; if ( componentType . isPrimitive ( ) ) { if ( componentType == int . class ) { return ArraysUtil . toStringArray ( ( int [ ] ) value ) ; } else if ( componentType == long . class ) { return ArraysUtil . toStringArray ( ( long [ ] ) value ) ; } else if ( componentType == double . class ) { return ArraysUtil . toStringArray ( ( double [ ] ) value ) ; } else if ( componentType == float . class ) { return ArraysUtil . toStringArray ( ( float [ ] ) value ) ; } else if ( componentType == boolean . class ) { return ArraysUtil . toStringArray ( ( boolean [ ] ) value ) ; } else if ( componentType == short . class ) { return ArraysUtil . toStringArray ( ( short [ ] ) value ) ; } else if ( componentType == byte . class ) { return ArraysUtil . toStringArray ( ( byte [ ] ) value ) ; } else { throw new IllegalArgumentException ( ) ; } } else { return ArraysUtil . toStringArray ( ( Object [ ] ) value ) ; } }
converts an array object to array of strings , where every element of input array is converted to a string . if input is not an array , the result will still be an array with one element .
