Here you can find the source of loadModel(String fileName, Hashtable
public static void loadModel(String fileName, Hashtable<String, String> dictionary, Hashtable<String, ArrayList<String>> modelPairs)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Hashtable; public class Main { public static void loadModel(String fileName, Hashtable<String, String> dictionary, Hashtable<String, ArrayList<String>> modelPairs) { //Open the model file BufferedReader reader = null; try {// w w w . j a v a2s . c o m reader = new BufferedReader(new InputStreamReader( new FileInputStream(fileName), "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } //Read each line String line = null; try { while ((line = reader.readLine()) != null) { // Comments, empty lines line = line.trim(); if (line.length() == 0 || line.charAt(0) == '#') continue; // Assign a word to our dictionary String[] halves = line.split("="); String mm = halves[0].trim(); String roman = halves[1].trim(); dictionary.put(mm, roman); if (modelPairs != null) { if (!modelPairs.containsKey(roman)) modelPairs.put(roman, new ArrayList<String>()); modelPairs.get(roman).add(mm); } } } catch (IOException ex) { ex.printStackTrace(); } try { reader.close(); } catch (IOException ex) { ex.printStackTrace(); } } }