LinkedHashMap声明如下:
public class Search {
private LinkedHashMap<String, String> Pairs;
什么是readSurnames()方法实际上是在引用LinkedHashMap?
inputStream是否只是一个文件,例如txt文件?
这条代码特别令我困惑:
Pairs.put(currentLine, processName(currentLine));
ReadSurnames:
/**
* Reads the surnames from the InputStream that was supplied on object
* creation
*/
public void readSurnames() {
String currentLine;
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNext()) {
currentLine = scanner.nextLine();
Pairs.put(currentLine, processName(currentLine));
}
try {
inputStream.close();
scanner.close();
} catch (IOException e) {
System.err
.println("An error occured closing the input stream and scanner");
}
}
流程名称:
/**
* Takes an initial name and processed to produce a phonetic version that
* can be compared against other processed names
*
* @param name
* The original name unprocessed name
* @return The phonetic equivalent of the input name
*/
public String processName(String name) {
name = processNonAlphabetic(name);
name = processDiscardedLetters(name);
name = processEquivalentLetters(name);
name = processDuplicateEquivalentLetters(name);
return name;
}
答案 0 :(得分:0)
对于每一行,它将原始行映射到行的已处理版本,因此,如果您有原始行,则可以访问已处理的版本。