Are there any api's to connect a method to a document to read data from it. Lets say I want the program to save all user names. And, display them if requested. I store all usernames in usernames.txt, how do I access the file's data?

I am only asking for some API's not the code to do it.