Java Vector to String vectorString(Vector vec)

Here you can find the source of vectorString(Vector vec)

Description

This method returns a string containing all the elements in vec concatenated together, comma separated.

License

Open Source License

Declaration


public static String vectorString(Vector vec) 

Method Source Code


//package com.java2s;
/*/*  ww  w.ja va 2 s  .c o m*/
    
  VectorUtils.java
    
  Convenience methods for working with Vectors.. provides efficient Union,
  Intersection, and Difference methods.
      
  Created: 21 July 1998
  Release: $Name:  $
  Version: $Revision: 1.21 $
  Last Mod Date: $Date: 2002/11/01 02:25:10 $
  Module By: Jonathan Abbey, jonabbey@arlut.utexas.edu
    
  -----------------------------------------------------------------------
          
  Ganymede Directory Management System
    
  Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
  The University of Texas at Austin.
    
  Contact information
    
  Web site: http://www.arlut.utexas.edu/gash2
  Author Email: ganymede_author@arlut.utexas.edu
  Email mailing list: ganymede@arlut.utexas.edu
    
  US Mail:
    
  Computer Science Division
  Applied Research Laboratories
  The University of Texas at Austin
  PO Box 8029, Austin TX 78713-8029
    
  Telephone: (512) 835-3200
    
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
    
  This program 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 General Public License for more details.
    
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    
*/

import java.util.*;

public class Main {
    /**
     * <P>This method returns a string containing all the elements in vec
     * concatenated together, comma separated.</P>
     */

    public static String vectorString(Vector vec) {
        if (vec == null) {
            return "";
        }

        StringBuffer temp = new StringBuffer();

        for (int i = 0; i < vec.size(); i++) {
            if (i > 0) {
                temp.append(",");
            }

            temp.append(vec.elementAt(i));
        }

        return temp.toString();
    }
}

Related

  1. convertVectorToStringArray(Vector vector)
  2. toStringArray(Vector V)
  3. vector2string(AbstractList v, String sep)
  4. vector2String(Vector v, String delimiter)
  5. vector_to_strings(Vector v)
  6. vectorToNickNameArray(Vector nicksAndPaths)
  7. vectorToString(double[] v)
  8. vectorToString(int[] v)
  9. vectorToStringArray(Vector vector)