Here you can find the source of objectArrayToStringArray(final Object[] objectArray)
Parameter | Description |
---|---|
objectArray | the Object array |
public static String[] objectArrayToStringArray(final Object[] objectArray)
//package com.java2s; /*/*from w w w. ja v a 2 s . c o m*/ * Copyright 2007 Kasper B. Graversen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Converts an Object array to a String array (null-safe), by calling toString() on each element. * * @param objectArray * the Object array * @return the String array, or null if objectArray is null */ public static String[] objectArrayToStringArray(final Object[] objectArray) { if (objectArray == null) { return null; } final String[] stringArray = new String[objectArray.length]; for (int i = 0; i < objectArray.length; i++) { stringArray[i] = objectArray[i] != null ? objectArray[i].toString() : null; } return stringArray; } }