nThe most sophisticated implementation of Java, Python and C++ do not use single algorithm for this type of search.
The decision upon what algorithm to use will be decided as a result of text size, search frequency, distribution of words etc.. (multiple algorithms could be used together also)
if the text is large, and you need to search only few words in a text, most of the implementation use extended version of Boyer-Moore or Rabin-Karp algorithms.
algorithm like Rabin-Karp for example search a hash match and if it is found it than searches the whole word , with good rolling hash function it will happen rarely,
Storing a Set of Text words seems to be a better solution vs your first suggestion, Although storing a Hashed values of you words can be even better solution (with additional mapping between the hash values and real words).
If your text has high distinctiveness it will not meter to hold the set. You have much more solutions that what you have suggested, i advice you to use google.