Java Vector to String toStringArray(Vector V)

Here you can find the source of toStringArray(Vector V)

Description

to String Array

License

Apache License

Declaration

public static String[] toStringArray(Vector V) 

Method Source Code


//package com.java2s;
/*/*w  w w  .j  av  a2s. co m*/
Copyright 2001-2015 Bo Zimmerman
    
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.
 */

import java.util.*;

public class Main {
    public static String[] toStringArray(Vector V) {
        if ((V == null) || (V.size() == 0)) {
            final String[] s = new String[0];
            return s;
        }
        final String[] s = new String[V.size()];
        for (int v = 0; v < V.size(); v++)
            s[v] = V.elementAt(v).toString();
        return s;
    }

    public static String[] toStringArray(HashSet V) {
        if ((V == null) || (V.size() == 0)) {
            final String[] s = new String[0];
            return s;
        }
        final String[] s = new String[V.size()];
        int v = 0;
        for (final Iterator i = V.iterator(); i.hasNext();)
            s[v++] = (i.next()).toString();
        return s;
    }

    public static String[] toStringArray(Hashtable V) {
        if ((V == null) || (V.size() == 0)) {
            final String[] s = new String[0];
            return s;
        }
        final String[] s = new String[V.size()];
        int v = 0;
        for (final Enumeration e = V.keys(); e.hasMoreElements();) {
            final String KEY = (String) e.nextElement();
            s[v] = (String) V.get(KEY);
            v++;
        }
        return s;
    }
}

Related

  1. convertVectorToString(Vector source, String separator)
  2. convertVectorToStringArray(Vector vector)
  3. vector2string(AbstractList v, String sep)
  4. vector2String(Vector v, String delimiter)
  5. vector_to_strings(Vector v)
  6. vectorString(Vector vec)