Java Vector to String vectorToNickNameArray(Vector nicksAndPaths)

Here you can find the source of vectorToNickNameArray(Vector nicksAndPaths)

Description

vectorToNickNameArray

License

Open Source License

Parameter

Parameter Description
nicksAndPaths - vector of library name and path lines

Return

- an array of string todo: change to java's Property class

Declaration

public static String[] vectorToNickNameArray(Vector nicksAndPaths) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    /**//from w ww  .j  a v  a2  s .  co  m
     * vectorToNickNameArray
     * @param nicksAndPaths - vector of library name and path lines
     * @return - an array of string
     * todo: change to java's Property class
     */
    public static String[] vectorToNickNameArray(Vector nicksAndPaths) {
        int i, j;
        String line;

        i = 0;
        j = 0;
        int sz = nicksAndPaths.size();
        String[] result_buffer = new String[sz];
        String temp;

        while (i < sz) {
            // first element in string is nick name
            line = ((String) nicksAndPaths.elementAt(i)).trim();
            if (line.length() > 0) {
                temp = parseOutLibNickName(line);

                if (temp == null || temp.length() == 0) {
                    return (null);
                } else {
                    result_buffer[j] = temp;
                    j++;
                }
            }
            i++;
        }
        return (result_buffer);
    }

    /**
     * parseOutLibNickName
     * @param line - line to parse nickname from
     * @return  String
     * todo: change to java's Property class
     */
    public static String parseOutLibNickName(String line) {
        int spacenum;
        String resultBuffer;

        // first element in string is nick name
        spacenum = line.indexOf("=");
        if (spacenum <= 0) {
            return (null);
        } else {
            resultBuffer = (line.substring(0, spacenum)).trim();
        }
        return (resultBuffer);
    }
}

Related

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