Java Array Convert to convertArray(Object columns[], int minLength)

Here you can find the source of convertArray(Object columns[], int minLength)

Description

Returns an array from the columns.

License

Open Source License

Parameter

Parameter Description
columns columns to return
minLength minimum number of columns in return array

Return

arrray with column values

Declaration

public static String[] convertArray(Object columns[], int minLength) 

Method Source Code

//package com.java2s;
/*// w  w  w .j a v  a 2  s  .  c  om
 * This file is part of CSV package.
 *
 *  CSV is free software: you can redistribute it 
 *  and/or modify it under the terms of version 3 of the GNU 
 *  Lesser General Public  License as published by the Free Software 
 *  Foundation.
 *  
 *  CSV is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public 
 *  License along with CSV.  If not, see 
 *  <http://www.gnu.org/licenses/lgpl-3.0.html>.
 */

public class Main {
    /**
     * Returns an array from the columns.
     * This function exists for convinience to take care of minimum column count.
     * @param columns columns to return
     * @param minLength minimum number of columns in return array
     * @return arrray with column values
     */
    public static String[] convertArray(Object columns[], int minLength) {
        int colcount = minLength > 0 ? minLength : 0;
        if (columns != null)
            colcount = columns.length;

        String rc[] = new String[Math.max(colcount, minLength)];
        if (colcount > 0) {
            for (int i = 0; i < colcount; i++) {
                rc[i] = columns[i] != null ? columns[i].toString() : null;
            }
        }
        return rc;
    }
}

Related

  1. arrayToSv(String as[], String s)
  2. arrayToSVMLightString(int[] array)
  3. arrayToUpper(String[] values)
  4. arrayWithoutFirstsElement(final String[] array, final int elementsToRemove)
  5. convertArray(byte[] a)
  6. convertArray(String[] str)
  7. convertArray2String(String[] sources)
  8. convertArrayIndexToShipLetter(int i)
  9. convertArrayToCSVString(String[] s)