Java - Write code to get Tab Indexes in side a string

Requirements

Write code to get Tab Indexes

Demo

//package com.book2s;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] argv) {
        String text = "book2s\t.com";
        System.out.println(getTabIndexes(text));
    }/*from   w w w.j av  a  2 s . c  o  m*/

    public static List<Integer> getTabIndexes(String text) {
        List<Integer> tabIndexes = null;

        if (text != null) {
            tabIndexes = new ArrayList<Integer>();

            for (int i = 0; i < text.length(); i++) {
                if (text.charAt(i) == '\t') {
                    tabIndexes.add(Integer.valueOf(i));
                }
            }
        }

        return tabIndexes;
    }
}