0 Replies - 5521 Views - Last Post: 28 March 2011 - 10:35 AM

#1 mikehunt10  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-November 10

Hashmap set up and search

Posted 28 March 2011 - 10:35 AM

import java.io.*;
import java.util.*;

public class DictionaryMap {
	private Map<Integer, String> words= new HashMap<Integer, String>();

	private void Word(){
		int count=1;
		try {
			FileInputStream fis = new FileInputStream("dictionary.txt");
			BufferedReader br = new BufferedReader(new InputStreamReader(fis));

			String quote;
			while ((quote = br.readLine()) != null)   {
				words.put(count, quote);
		} catch (FileNotFoundException e) {
		} catch (IOException e) {

I would like to create a hashmap filled with strings from a "dictionary.txt" file which I would then like to search for similar words.However, I can't seem to store the text file within my eclipse project. I would rather do this than store in a folder on the computer.
So far I have only created the map, I'm not sure whether I should create a seperate class for the search or to do it in the same class. Any points in the right direction would be much appreciated.
Many thanks

Is This A Good Question/Topic? 0
  • +

Page 1 of 1