An obvious way to generate permutations of n is to generate values for the Lehmer code (possibly using the factorial number system representation of integers up to n!), and convert those into the corresponding permutations. However the latter step, while straightforward, is hard to implement efficiently, because it requires n operations each of selection from a sequence and deletion from it, at an arbitrary position; of the obvious representations of the sequence as an array or a linked list, both require (for different reasons) about n2/4 operations to perform the conversion. With n likely to be rather small (especially if generation of all permutations is needed) that is not too much of a problem, but it turns out that both for random and for systematic generation there are simple alternatives that do considerably better. For this reason it does not seem useful, although certainly possible, to employ a special data structure that would allow performing the conversion from Lehmer code to permutation in O(n logn) time.
You could try to do some research on what I found for you above and try to generate all possible permutations of your String. Then, you could use a dictionary as your text file and look up each permutation using a binary search. Binary search works basically like you'd think it would for searching a dictionary: start in the middle, if your word is higher than the word in the middle, throw out the bottom half of the dictionary. Then go to …