Here you can find the source of splitIntegerFromString(String str)
public static List<Integer> splitIntegerFromString(String str)
//package com.java2s; /*/*from w w w . j a v a 2s . c o m*/ * Copyright 1998-2012 360buy.com All right reserved. This software is the confidential and proprietary information of * 360buy.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with 360buy.com. */ import java.util.ArrayList; import java.util.List; public class Main { public static List<Integer> splitIntegerFromString(String str) { List<Integer> integerList = null; if (null == str) { return integerList; } integerList = new ArrayList<Integer>(); String numDict = "0123456789"; char[] strChars = str.toCharArray(); StringBuffer sbuffer = new StringBuffer(); for (char ch : strChars) { if (numDict.indexOf(ch) != -1) { sbuffer.append(ch); } else { if (sbuffer.length() > 0) { integerList.add(Integer.valueOf(sbuffer.toString())); sbuffer.setLength(0); } continue; } } if (sbuffer.length() > 0) { integerList.add(Integer.valueOf(sbuffer.toString())); sbuffer.setLength(0); } return integerList; } }