It is a small program ... public class hanzipinyin {public static void change (string path, string paths, string savepaths) {file d = new file (path); // get a list of all files and directories under the current folder File Lists [] = D.ListFiles (); string pathss = new string ("");
/ / Retrieve FOR (INT I = 0; I // Define file type string file input filety = new string (""); FileType = filename.substring ((Filename.Length () - 3), filename.length ()); if (filetype.equals ("doc")) {system.out.println ("-------- / n Currently being converted ... "); // Print the current directory path system.out.println (path); // Print the doc file name system.out.println (RealFileName); // Start Word ActiveXComponent Apponent Apponent APP = New ActiveXComponent ("Word.Application"); string docpath = paths filename; string txtpath = savePaths fullsavefilename ".htm"; // format file name txtpath = formatName (txtpath); // Transform Chinese file name For pinyin txtpath = pinyin (path, txtpath); // to convert Word file string infile = docpath; // txt file string tpfile = txtpath; Boolean flag = false; try {// Setting Word Not visible App.SetProperty ("Visible", New Variant (false)); Object Docs = App.getProperty ("Documents"). Todispatch (); // Open Word file Object Doc = dispatch.invoke (DOCS, "Open", Dispatch.method, New Object [] {Infile, New Variant (false), New Variant (TRUE)}, new int [1]). Todispatch (); // TXT format Save to Temporary Document Dispatch.Invoke (DOC, "Saveas", Dispatch.Method, New Object [] {TPFILE, New Variant (10)}, new int rt [1]); Variant F = New Variant (false); Dispatch.call (DOC, "Close", F); FLAG = true;} catch (exception e) {E.PrintStackTrace ();} finally {app.invoke ("quit", new variant [] {};} System.out.println ("Transformation is completed! / N ------");}} else {pathss = paths; // Go to the next directory Pathss = Pathss Lists [i] .GetName () "//"; // Remature traversal all directory Change (path, pathss, savepaths);}}} public static string formatName (String Name) {name = name. Replace (',', '_'); name = name.replace (')', ')'); Name = Name.Replace ('('); return name;} public static string Pinyin String Path, String Hanzi) {file f = new file (path); string pinyin = new string (""); pinyin = hanzi; tryler (f); bufferedreader br = New BufferedReader (fr); String line = new string (""); Line = br.readline (); int count = 0; int location = 0; while (line! = null) {while (Pinyin.indexof (Line.Charat (0))! = -1) {location = Pinyin.indexof (line.charat (0)); Pinyin = Pinyin.substring (0, location) line.substring (1, 2) Pinyin.Substring (location 1, Pinyin.Length ());} line = br.readline (); System.out.print ("/ B / B / B / B / B / B" COUNT );} fr.close (); br.close ();} catch (exception e) {// system ("d: ////2004.10.8//test system //2004.10.8//test system //2004.10.8//test system //2004.10.8//test system // TEST01 //////te {= = Word // "); String SavePath = New String (" D: //Work//2004.10.8/test system // TEST01 // html // "); string path = new string (" D: // Test //file/pinyin.txt "); Change (path, paths, savepaths);}} The pinyin and Chinese characters can be obtained from the Windows self-proper program.