Here you can find the source of findAll(final String s, final String subs)
public static int[] findAll(final String s, final String subs)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { public static int[] findAll(final String s, final String subs) { if (s.length() == 0 || subs.length() == 0) return null; ArrayList<Integer> indices = new ArrayList<Integer>(); int i = 0; int len = subs.length(); int i0;// www . j a v a 2 s .com while ((i0 = s.substring(i, s.length()).indexOf(subs, i)) != -1) { indices.add(i0 + i); i += s.indexOf(subs, i) + len; } int[] r = new int[indices.size()]; for (int n = 0; n < indices.size(); ++n) r[n] = indices.get(n); return r; } }