Request input English translation into Chinese
Input help output all words
Import Java.io.bufferedreader;import java.io.file;import java.io.fileinputstream;import java.io.InputStreamReader; Import Java.util.iterator;import java.util.map;import Java.util.scanner;import Java.util.treemap;public class Readdic {public static string Readdicfile (String filePath) {string result = ""; try {String encoding = "GBK"; File File = new file (FilePath); if (File.isfile () && file.exists ()) {//Determine if the file exists inputstreamreader read = new InputStreamReader (new file InputStream (file), encoding);//considering the encoding format BufferedReader BufferedReader = new BufferedReader (read); String dicfulltext = null; while ((Dicfulltext = Bufferedreader.readline ()) = null) {result = Dicfulltext; } read.close (); } else {System.out.println ("The specified file cannot be found"); }} catch (Exception e) {System.out.println ("Error reading file contents"); E.printstacktrace (); } return result; }/** * @param args */public static void main (string[] args) {Scanner cin = new Scanner (system.in); StRing input = Cin.next (); String Dicpath = "D:/zhangyayun 13057655618/dic/doc.txt"; String result = Readdicfile (Dicpath); String dictext[] = Result.split ("\\|"); TREEMAP TM = new TreeMap (); for (int i = 0; i < dictext.length; i++) {String temp = dictext[i]; String temparray[] = temp.split ("="); Tm.put (Temparray[0], temparray[1]); } if (Input.equals ("Help")) {Iterator it = Tm.entryset (). Iterator (); while (It.hasnext ()) {Map.entry Entry = (map.entry) it.next (); Object key = Entry.getkey (); Object value = Entry.getvalue (); SYSTEM.OUT.PRINTLN (key + "" + value); }} else {string dicresult = (string) tm.get (input); if (Dicresult! = null) {System.out.println (Tm.get (input)); } else {System.out.println ("input error"); } } }}
Help
Hello, hi.
Man Men
Welcome Welcome
On-Machine topic (advanced)-Electronic dictionary (Java)