How to store file input into a hash table in Java? -


I am trying to store data from an input file in a hash in Java, but I do not know That's how to do that.

The data will look something like this:

  Apple orange bananas  

Then each letter in apple hash table Then every character in orange will be in a different hash table. I want to be able to compare letters in apple and orange. How can I do this?

It has so far to me.

if (args.length == 0) {return; } BufferedReader br; Try {br = new BufferedReader (new FileReader ("input.txt")); } Hold (FileNotFoundException fnfe) {System.out.println ("File not found"); Return; } MyHashTable mht = New MyHashTable (); {String line; While (breadline (!! = Null) {mht.insert (line); }} Hold (IOException ioe) {System.out.println (ioe); Return; }

You can read by using stringbuffers and then just open the apple vene and banana set can do. You need to write code to compare each letter. You can use comparable or comparator by using the collection class


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -