Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.*;

public class Main {
    public static int[] stringToIntArray(String s) {
        if (s == null || s.equals("")) {
            return new int[0];
        }
        List<Integer> v = new ArrayList<Integer>();
        String[] sa = s.split(";");
        for (int i = 0; i < sa.length; i++) {
            try {
                v.add(new Integer(sa[i]));
            } catch (NumberFormatException e) {
            }
        }
        int[] ia = new int[v.size()];
        for (int i = 0; i < ia.length; i++) {
            ia[i] = v.get(i).intValue();
        }
        return ia;
    }
}