Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Title:        efa - elektronisches Fahrtenbuch fr Ruderer
 * Copyright:    Copyright (c) 2001-2011 by Nicolas Michael
 * Website:      http://efa.nmichael.de/
 * License:      GNU General Public License v2
 *
 * @author Nicolas Michael
 * @version 2
 */

import java.util.*;

public class Main {
    public static String[] kommaList2Arr(String s, char sep) {
        if (s == null) {
            return null;
        }
        Vector v;
        if (s.length() > 0) {
            v = split(s, sep);
        } else {
            v = new Vector();
        }
        String[] aa = new String[v.size()];
        for (int ii = 0; ii < v.size(); ii++) {
            aa[ii] = (String) v.get(ii);
        }
        return aa;
    }

    public static Vector<String> split(String s, char sep) {
        if (s == null) {
            return null;
        }
        Vector v = new Vector<String>();
        while (s.length() != 0) {
            int pos = s.indexOf(sep);
            if (pos >= 0) {
                v.add(s.substring(0, pos));
                s = s.substring(pos + 1, s.length());
                if (s.length() == 0) {
                    v.add(""); // letztes (leeres) Element hinter letztem Trennzeichen
                }
            } else if (s.length() > 0) {
                v.add(s);
                s = "";
            }
        }
        return v;
    }

    public static String[] split(String s, String sep) {
        if (s == null) {
            return null;
        }
        ArrayList<String> list = new ArrayList<String>();
        while (s.length() != 0) {
            int pos = s.indexOf(sep);
            if (pos >= 0) {
                list.add(s.substring(0, pos));
                s = s.substring(pos + sep.length(), s.length());
                if (s.length() == 0) {
                    list.add(""); // letztes (leeres) Element hinter letztem Trennzeichen
                }
            } else if (s.length() > 0) {
                list.add(s);
                s = "";
            }
        }
        return list.toArray(new String[0]);
    }
}