Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    static HashMap<String, String> irregularVerbMap = new HashMap<String, String>();
    public static final String FILE_NAME_IRREGULAR_VERB = "irregular verb.idx";

    public static void initializeIrregularVerbMap() {
        try {
            BufferedReader reader = new BufferedReader(new FileReader(new File(FILE_NAME_IRREGULAR_VERB)));
            String line = null;
            while ((line = reader.readLine()) != null) {
                StringTokenizer tokenizer = new StringTokenizer(line, "\t\n", false);
                String root = null;
                if (tokenizer.hasMoreTokens())
                    root = tokenizer.nextToken().trim();

                while (tokenizer.hasMoreTokens()) {
                    irregularVerbMap.put(tokenizer.nextToken().trim(), root);
                }
            }
        } catch (FileNotFoundException e) {
            System.out.println("File not found in the system.");
        } catch (IOException e1) {
            System.out.println("IOException");
        }
    }
}