Here you can find the source of loadCommonMisspellingsFile(String commonMisspellingsFileLocation)
public static Map<String, String> loadCommonMisspellingsFile(String commonMisspellingsFileLocation)
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.HashMap; import java.util.Map; public class Main { public static Map<String, String> loadCommonMisspellingsFile(String commonMisspellingsFileLocation) { Map<String, String> commonMisspellingsMap = null; if (commonMisspellingsFileLocation != null) { commonMisspellingsMap = new HashMap<String, String>(); BufferedReader br = null; FileReader fr = null; try { fr = new FileReader(commonMisspellingsFileLocation); br = new BufferedReader(fr); while (true) { String line = br.readLine(); if (line == null || line.trim().length() == 0) { break; }/* w ww . jav a 2 s .com*/ int indexOfSeparator = line.indexOf("->"); String incorrect = line.substring(0, indexOfSeparator); String correct = line.substring(indexOfSeparator + 2); indexOfSeparator = correct.indexOf(","); if (indexOfSeparator != -1) { correct = correct.substring(0, indexOfSeparator); } // add to the map; no need to lowercase correct spelling (we want America to remain America) commonMisspellingsMap.put(incorrect.toLowerCase(), correct); } } catch (Throwable thr) { String msg = "Error while parsing input file '" + commonMisspellingsFileLocation + "'!"; throw new IllegalArgumentException(msg, thr); } finally { if (fr != null) { try { fr.close(); } catch (IOException e) { throw new RuntimeException(e); } } if (br != null) { try { br.close(); } catch (IOException e) { throw new RuntimeException(e); } } } } return commonMisspellingsMap; } }