February 23rd, 2014, 04:01 AM
Retrieving file contents
I am creating some sort of a dictionary and i am trying to make a text file as my database. in example, my text.txt file contains these:
-To take into the body by the mouth for digestion or absorption
-To take into the mouth and swallow (a liquid).
the user then typed the word EAT in the text field and clicked the search button. So how am i gonna retrieve the word EAT and its DEFINITION from the text file? i know i have to use the File class, fileInputStream.
i already created the application but i used string matching, i included those words in an array in my source code. now i wanted to try reading/retrieving contents from a text file. any idea how to do this?
February 23rd, 2014, 08:40 AM
There are several classes that will help. Scanner class is the simplest. Or try the FileReader wrapped in a BufferedReader.
Use a Map to hold the words and their meanings.
February 23rd, 2014, 11:03 AM
what do you mean by map?
Originally Posted by NormR
February 23rd, 2014, 11:06 AM
See the java SE API doc for a description of the Map interface.