从控制台读入输入
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String saids = br.readLine();
从文件中读入数据
HashMap<String, String> trans_map = new HashMap<String, String>();
String trans_path = "d://trans_map.txt";
FileReader fr = new FileReader(trans_path); BufferedReader br = new BufferedReader(fr); String line = br.readLine(); while (line != null) { String[] words = line.split(" "); trans_table.put(words[0], words[1]); line = br.readLine(); }