Hi i am new to java i hope i could find the answer to my problem..i am tying to write a program using hashmap where i am taking input from a file containing hindi characters(Indian language)mapping each character to 1st hashmap from which i get the corresponding value(unicode value of each character) then taking that value to another hashmap from which i get corresponding value(unicode value of the same character in a different language) this should be taken to the third hash map and retrive corresponding key(Corresponding character).. The first two mapping is working fine but when making mapping to the 3rd hashmap its returning null instead of the key which is a character in kannada(Indian language).This program is to transiliterate file in one language to another.
Object x=kannadahash.get("w"); is the part i am getting null instead of the character
The code i have written:
Any other suggestion in doing this differently would also be welcome Thank you in advance..
import java.util.*;
import java.util.Properties;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.Enumeration;
import java.util.Collections;
public class Hashmap1 {
public static void main(String[] args) throws Exception
HashMap hindihash=new HashMap();
hindihash.put("अ",905);
hindihash.put("आ",906);
HashMap kannadahash=new HashMap();
kannadahash.put("ಅ","C85" );
kannadahash.put("ಆ","C86");
HashMap hkhash = new HashMap();
hkhash.put(905,"C85" );
hkhash.put(906,"C86");
File f = new File("D:/Hello.txt");
if (!f.exists() && f.length() < 0)
{
System.out.println("The specified file does not exist");
}
else
{
FileReader fr = new FileReader(f);
BufferedReader reader = new BufferedReader(fr);
String st = " ";
while ((st = reader.readLine()) != null)
{
Object v = hindihash.get(st);
Object w=hkhash.get(v);
if(w!=null)
{
System.out.println(" "+w.toString());
}
else
{
System.out.println("There is no key named " +
"in the HashMap.");
}
Object x=kannadahash.get("w");
if(x!=null)
{
System.out.println(" "+x.toString());
}
else
{
System.out.println("There is no key named " +
"in the HashMap.");
}
}
}
}