#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2

    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:

    eat
    -To take into the body by the mouth for digestion or absorption

    drink
    -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?
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    reading/retrieving contents from a text file
    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.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2
    Originally Posted by NormR
    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.
    what do you mean by map?
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    See the java SE API doc for a description of the Map interface.

IMN logo majestic logo threadwatch logo seochat tools logo