Java List to Int List toIntList(String arr, String separator)

Here you can find the source of toIntList(String arr, String separator)

Description

to Int List

License

LGPL

Declaration

public static List<Integer> toIntList(String arr, String separator) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<Integer> toIntList(String arr, String separator) {
        String[] array = arr.split(separator);
        List<Integer> r = new ArrayList<Integer>(array.length + 1);

        for (int i = 0; i < array.length; i++) {
            r.add(Integer.parseInt(array[i]));
        }// w  w w. ja  va  2 s .  c  om

        return r;
    }
}

Related

  1. toIntegerList(List strList, boolean failOnException)
  2. toIntegers(final List longs)
  3. toIntegers(List values)
  4. toIntList(List list)
  5. toIntList(Set members)
  6. toInts(List list)