Here you can find the source of getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion)
public static List<String> getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion) { String argumentToFindCompletionFor = args[args.length - 1]; List<String> listOfPossibleCompletions = new ArrayList<String>(); for (int i = 0; i < possibilitiesOfCompletion.length; ++i) { String foundString = possibilitiesOfCompletion[i]; if (foundString.regionMatches(true, 0, argumentToFindCompletionFor, 0, argumentToFindCompletionFor.length())) { listOfPossibleCompletions.add(foundString); }/*from w ww . ja v a 2 s.c o m*/ } return listOfPossibleCompletions; } }