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
*/