Here you can find the source of getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion)
public static List<String> getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion)
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static List<String> getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion) { final String argumentToFindCompletionFor = args[args.length - 1]; final List<String> listOfPossibleCompletions = new ArrayList<String>(); for (int i = 0; i < possibilitiesOfCompletion.length; i++) { final String[] foundString = possibilitiesOfCompletion; try { if (foundString[i] != null && foundString[i].regionMatches(true, 0, argumentToFindCompletionFor, 0, argumentToFindCompletionFor.length())) { listOfPossibleCompletions.add(foundString[i]); }/*from www.j a v a 2 s .co m*/ } catch (final Exception e) { e.printStackTrace(); } } Collections.sort(listOfPossibleCompletions); return listOfPossibleCompletions; } }