Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Networking TechnologyRSS Feeds

Program which simulate the dictionary in java

Posted By: Lulie Fischer     Category: Java     Views: 15376

Write a program which simulate the dictionary in java.

Code for Program which simulate the dictionary in java in Java

import java.io.*;

class dictionary
{
    publicstaticvoid main(String args[])
    {
        int i;
        boolean flag = false;
        String sub = new String();
        String strf = new String();

        try
        {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = br.readLine();
            FileReader fr = new FileReader("dictionaryTXT.txt");
            BufferedReader bb = new BufferedReader(fr);
            
            while((strf = bb.readLine()) != null)
            {
                i = strf.indexOf(":");
                sub = strf.substring(0,i);
                if(str.equals(sub))
                {
                    System.out.println(strf);
                    flag=true;
                }
        
            }
            bb.close();

            if(!flag)
                System.out.println("Word not found");

        }catch(Exception e)
        {
            System.out.println(e);
        }
    }
}


/*
Output

dictionaryTXT

blame:to find fault.
compete:to try to do better than one's fellow in work.
daring:courage.
errant:wandering.
futile:worthless.
goodwill:kindly feeling.


E:\>java dictionary
daring
daring:courage.

E:\>java dictionary
Vidyadhar
Word not found

*/
  
Share: 


Didn't find what you were looking for? Find more on Program which simulate the dictionary in java Or get search suggestion and latest updates.

Lulie Fischer
Lulie Fischer author of Program which simulate the dictionary in java is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!