锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 銆銆GUI浠g爜閮ㄥ垎錛?/p> 銆銆/** 銆銆* @(#)CnToSpellGUI.java 銆銆* kindani 銆銆* 2004-10-25?? 銆銆* */ 銆銆import java.awt.*; 銆銆import java.awt.event.*; 銆銆import javax.swing.*; 銆銆import javax.swing.event.*; 銆銆/** 銆銆* 銆銆* 銆銆JDK鐗堟湰 銆銆1.4 銆銆* @author KIN 銆銆* @version 1.0 銆銆* @see 銆銆* @since 1.0 銆銆*/ 銆銆public class CnToSpell2GUI extends JFrame { 銆銆private CnToSpell2GUI c = null; 銆銆public CnToSpell2GUI () { 銆銆super("Cn to Spell"); 銆銆setSize(800,100); 銆銆getContentPane().setLayout(new FlowLayout()); 銆銆// component layout 銆銆JTextArea from = new JTextArea(5,20); 銆銆JTextArea to = new JTextArea(5,20); 銆銆JButton b = new JButton("cn to pinyin"); 銆銆getContentPane().add(new JLabel("From:")); 銆銆getContentPane().add(from); 銆銆getContentPane().add(b); 銆銆getContentPane().add(new JLabel("To:")); 銆銆getContentPane().add(to); 銆銆// action handle 銆銆b.addActionListener(new Cn2PinyinActionListener(from,to)); 銆銆setVisible(true); 銆銆// set this for pack 銆銆c = this; 銆銆} 銆銆class Cn2PinyinActionListener implements ActionListener{ 銆銆private JTextArea from = null; 銆銆private JTextArea to = null; 銆銆public Cn2PinyinActionListener(JTextArea from, JTextArea to) { 銆銆this.from = from; 銆銆this.to = to; 銆銆} 銆銆public void actionPerformed(ActionEvent e) { 銆銆if (from.getText().length() == 0) { 銆銆JOptionPane.showMessageDialog(from,"From text is empty!","Warning",JOptionPane.WARNING_MESSAGE); 銆銆} 銆銆String text = from.getText(); 銆銆to.setText(CnToSpell.getFullSpell(text)); 銆銆c.pack(); 銆銆} 銆銆} 銆銆public static void main(String [] args) { 銆銆CnToSpell2GUI g = new CnToSpell2GUI(); 銆銆} 銆銆} 銆銆銆/** 銆銆* @(#)CnToSpell.java 銆銆* 鐗堟潈澹版槑 Easydozer 鐗堟潈鎵鏈?榪濊呭繀絀?/p> 銆銆* 銆銆* 淇璁板綍: 銆銆* 1)鏇存敼鑰咃細Easydozer 銆銆* 鏃躲闂達細2004-10-20 銆銆* 鎻忋榪幫細鍒涘緩 銆銆*/ 銆銆package com.easydozer.commons.util; 銆銆import java.util.Iterator; 銆銆import java.util.LinkedHashMap; 銆銆import java.util.Set; 銆銆/** 銆銆* 銆銆姹夊瓧杞寲涓哄叏鎷?/p> 銆銆* 銆銆JDK鐗堟湰: 銆銆1.4 銆銆* @author 璋㈣鐢?/p> 銆銆* @version 1.0 銆銆* @see 銆銆* @since 1.0 銆銆*/ 銆銆public class CnToSpell 銆銆{ 銆銆private static LinkedHashMap spellMap = null; 銆銆static 銆銆{ 銆銆if(spellMap == null){ 銆銆spellMap = new LinkedHashMap(400); 銆銆} 銆銆initialize(); 銆銆System.out.println("Chinese transfer Spell Done."); 銆銆} 銆銆{ 銆銆} 銆銆private static void spellPut(String spell,int ascii) 銆銆{ 銆銆spellMap.put(spell,new Integer(ascii)); 銆銆} 銆銆private static void initialize() 銆銆{ 銆銆spellPut("a", -20319); 銆銆spellPut("ai", -20317); 銆銆spellPut("an", -20304); 銆銆spellPut("ang", -20295); 銆銆spellPut("ao", -20292); 銆銆spellPut("ba", -20283); 銆銆spellPut("bai", -20265); 銆銆spellPut("ban", -20257); 銆銆spellPut("bang", -20242); 銆銆spellPut("bao", -20230); 銆銆spellPut("bei", -20051); 銆銆spellPut("ben", -20036); 銆銆spellPut("beng", -20032); 銆銆spellPut("bi", -20026); 銆銆spellPut("bian", -20002); 銆銆spellPut("biao", -19990); 銆銆spellPut("bie", -19986); 銆銆spellPut("bin", -19982); 銆銆spellPut("bing", -19976); 銆銆spellPut("bo", -19805); 銆銆spellPut("bu", -19784); 銆銆spellPut("ca", -19775); 銆銆spellPut("cai", -19774); 銆銆spellPut("can", -19763); 銆銆spellPut("cang", -19756); 銆銆spellPut("cao", -19751); 銆銆spellPut("ce", -19746); 銆銆spellPut("ceng", -19741); 銆銆spellPut("cha", -19739); 銆銆spellPut("chai", -19728); 銆銆spellPut("chan", -19725); 銆銆spellPut("chang", -19715); 銆銆spellPut("chao", -19540); 銆銆spellPut("che", -19531); 銆銆spellPut("chen", -19525); 銆銆spellPut("cheng", -19515); 銆銆spellPut("chi", -19500); 銆銆spellPut("chong", -19484); 銆銆spellPut("chou", -19479); 銆銆spellPut("chu", -19467); 銆銆spellPut("chuai", -19289); 銆銆spellPut("chuan", -19288); 銆銆spellPut("chuang", -19281); 銆銆spellPut("chui", -19275); 銆銆spellPut("chun", -19270); 銆銆spellPut("chuo", -19263); 銆銆spellPut("ci", -19261); 銆銆spellPut("cong", -19249); 銆銆spellPut("cou", -19243); 銆銆spellPut("cu", -19242); 銆銆spellPut("cuan", -19238); 銆銆spellPut("cui", -19235); 銆銆spellPut("cun", -19227); 銆銆spellPut("cuo", -19224); 銆銆spellPut("da", -19218); 銆銆spellPut("dai", -19212); 銆銆spellPut("dan", -19038); 銆銆spellPut("dao", -19018); 銆銆spellPut("de", -19006); 銆銆spellPut("deng", -19003); 銆銆spellPut("di", -18996); 銆銆spellPut("dian", -18977); 銆銆spellPut("diao", -18961); 銆銆spellPut("die", -18952); 銆銆spellPut("ding", -18783); 銆銆spellPut("diu", -18774); 銆銆spellPut("dong", -18773); 銆銆spellPut("dou", -18763); 銆銆spellPut("du", -18756); 銆銆spellPut("duan", -18741); 銆銆spellPut("dui", -18735); 銆銆spellPut("dun", -18731); 銆銆spellPut("duo", -18722); 銆銆spellPut("e", -18710); 銆銆spellPut("en", -18697); 銆銆spellPut("er", -18696); 銆銆spellPut("fa", -18526); 銆銆spellPut("fan", -18518); 銆銆spellPut("fang", -18501); 銆銆spellPut("fei", -18490); 銆銆spellPut("fen", -18478); 銆銆spellPut("feng", -18463); 銆銆spellPut("fo", -18448); 銆銆spellPut("fou", -18447); 銆銆spellPut("fu", -18446); 銆銆spellPut("ga", -18239); 銆銆spellPut("gai", -18237); 銆銆spellPut("gan", -18231); 銆銆spellPut("gang", -18220); 銆銆spellPut("gao", -18211); 銆銆spellPut("ge", -18201); 銆銆spellPut("gei", -18184); 銆銆spellPut("gen", -18183); 銆銆spellPut("geng", -18181); 銆銆spellPut("gong", -18012); 銆銆spellPut("gou", -17997); 銆銆spellPut("gu", -17988); 銆銆spellPut("gua", -17970); 銆銆spellPut("guai", -17964); 銆銆spellPut("guan", -17961); 銆銆spellPut("guang", -17950); 銆銆spellPut("gui", -17947); 銆銆spellPut("gun", -17931); 銆銆spellPut("guo", -17928); 銆銆spellPut("ha", -17922); 銆銆spellPut("hai", -17759); 銆銆spellPut("han", -17752); 銆銆spellPut("hang", -17733); 銆銆spellPut("hao", -17730); 銆銆spellPut("he", -17721); 銆銆spellPut("hei", -17703); 銆銆spellPut("hen", -17701); 銆銆spellPut("heng", -17697); 銆銆spellPut("hong", -17692); 銆銆spellPut("hou", -17683); 銆銆spellPut("hu", -17676); 銆銆spellPut("hua", -17496); 銆銆spellPut("huai", -17487); 銆銆spellPut("huan", -17482); 銆銆spellPut("huang", -17468); 銆銆spellPut("hui", -17454); 銆銆spellPut("hun", -17433); 銆銆spellPut("huo", -17427); 銆銆spellPut("ji", -17417); 銆銆spellPut("jia", -17202); 銆銆spellPut("jian", -17185); 銆銆spellPut("jiang", -16983); 銆銆spellPut("jiao", -16970); 銆銆spellPut("jie", -16942); 銆銆spellPut("jin", -16915); 銆銆spellPut("jing", -16733); 銆銆spellPut("jiong", -16708); 銆銆spellPut("jiu", -16706); 銆銆spellPut("ju", -16689); 銆銆spellPut("juan", -16664); 銆銆spellPut("jue", -16657); 銆銆spellPut("jun", -16647); 銆銆spellPut("ka", -16474); 銆銆spellPut("kai", -16470); 銆銆spellPut("kan", -16465); 銆銆spellPut("kang", -16459); 銆銆spellPut("kao", -16452); 銆銆spellPut("ke", -16448); 銆銆spellPut("ken", -16433); 銆銆spellPut("keng", -16429); 銆銆spellPut("kong", -16427); 銆銆spellPut("kou", -16423); 銆銆spellPut("ku", -16419); 銆銆spellPut("kua", -16412); 銆銆spellPut("kuai", -16407); 銆銆spellPut("kuan", -16403); 銆銆spellPut("kuang", -16401); 銆銆spellPut("kui", -16393); 銆銆spellPut("kun", -16220); 銆銆spellPut("la", -16212); 銆銆spellPut("lai", -16205); 銆銆spellPut("lan", -16202); 銆銆spellPut("lang", -16187); 銆銆spellPut("lao", -16180); 銆銆spellPut("le", -16171); 銆銆spellPut("lei", -16169); 銆銆spellPut("leng", -16158); 銆銆spellPut("li", -16155); 銆銆spellPut("lia", -15959); 銆銆spellPut("lian", -15958); 銆銆spellPut("liang", -15944); 銆銆spellPut("liao", -15933); 銆銆spellPut("lie", -15920); 銆銆spellPut("lin", -15915); 銆銆spellPut("ling", -15903); 銆銆spellPut("liu", -15889); 銆銆spellPut("long", -15878); 銆銆spellPut("lou", -15707); 銆銆spellPut("lu", -15701); 銆銆spellPut("lv", -15681); 銆銆spellPut("luan", -15667); 銆銆spellPut("lue", -15661); 銆銆spellPut("lun", -15659); 銆銆spellPut("luo", -15652); 銆銆spellPut("ma", -15640); 銆銆spellPut("mai", -15631); 銆銆spellPut("man", -15625); 銆銆spellPut("mang", -15454); 銆銆spellPut("mao", -15448); 銆銆spellPut("me", -15436); 銆銆spellPut("mei", -15435); 銆銆spellPut("men", -15419); 銆銆spellPut("meng", -15416); 銆銆spellPut("mi", -15408); 銆銆spellPut("mian", -15394); 銆銆spellPut("miao", -15385); 銆銆spellPut("mie", -15377); 銆銆spellPut("min", -15375); 銆銆spellPut("ming", -15369); 銆銆spellPut("miu", -15363); 銆銆spellPut("mo", -15362); 銆銆spellPut("mou", -15183); 銆銆spellPut("mu", -15180); 銆銆spellPut("na", -15165); 銆銆spellPut("nai", -15158); 銆銆spellPut("nan", -15153); 銆銆spellPut("nang", -15150); 銆銆spellPut("nao", -15149); 銆銆spellPut("ne", -15144); 銆銆spellPut("nei", -15143); 銆銆spellPut("nen", -15141); 銆銆spellPut("neng", -15140); 銆銆spellPut("ni", -15139); 銆銆spellPut("nian", -15128); 銆銆spellPut("niang", -15121); 銆銆spellPut("niao", -15119); 銆銆spellPut("nie", -15117); 銆銆spellPut("nin", -15110); 銆銆spellPut("ning", -15109); 銆銆spellPut("niu", -14941); 銆銆spellPut("nong", -14937); 銆銆spellPut("nu", -14933); 銆銆spellPut("nv", -14930); 銆銆spellPut("nuan", -14929); 銆銆spellPut("nue", -14928); 銆銆spellPut("nuo", -14926); 銆銆spellPut("o", -14922); 銆銆spellPut("ou", -14921); 銆銆spellPut("pa", -14914); 銆銆spellPut("pai", -14908); 銆銆spellPut("pan", -14902); 銆銆spellPut("pang", -14894); 銆銆spellPut("pao", -14889); 銆銆spellPut("pei", -14882); 銆銆spellPut("pen", -14873); 銆銆spellPut("peng", -14871); 銆銆spellPut("pi", -14857); 銆銆spellPut("pian", -14678); 銆銆spellPut("piao", -14674); 銆銆spellPut("pie", -14670); 銆銆spellPut("pin", -14668); 銆銆spellPut("ping", -14663); 銆銆spellPut("po", -14654); 銆銆spellPut("pu", -14645); 銆銆spellPut("qi", -14630); 銆銆spellPut("qia", -14594); 銆銆spellPut("qian", -14429); 銆銆spellPut("qiang", -14407); 銆銆spellPut("qiao", -14399); 銆銆spellPut("qie", -14384); 銆銆spellPut("qin", -14379); 銆銆spellPut("qing", -14368); 銆銆spellPut("qiong", -14355); 銆銆spellPut("qiu", -14353); 銆銆spellPut("qu", -14345); 銆銆spellPut("quan", -14170); 銆銆spellPut("que", -14159); 銆銆spellPut("qun", -14151); 銆銆spellPut("ran", -14149); 銆銆spellPut("rang", -14145); 銆銆spellPut("rao", -14140); 銆銆spellPut("re", -14137); 銆銆spellPut("ren", -14135); 銆銆spellPut("reng", -14125); 銆銆spellPut("ri", -14123); 銆銆spellPut("rong", -14122); 銆銆spellPut("rou", -14112); 銆銆spellPut("ru", -14109); 銆銆spellPut("ruan", -14099); 銆銆spellPut("rui", -14097); 銆銆spellPut("run", -14094); 銆銆spellPut("ruo", -14092); 銆銆spellPut("sa", -14090); 銆銆spellPut("sai", -14087); 銆銆spellPut("san", -14083); 銆銆spellPut("sang", -13917); 銆銆spellPut("sao", -13914); 銆銆spellPut("sen", -13907); 銆銆spellPut("seng", -13906); 銆銆spellPut("sha", -13905); 銆銆spellPut("shai", -13896); 銆銆spellPut("shan", -13894); 銆銆spellPut("shang", -13878); 銆銆spellPut("shao", -13870); 銆銆spellPut("she", -13859); 銆銆spellPut("shen", -13847); 銆銆spellPut("sheng", -13831); 銆銆spellPut("shi", -13658); 銆銆spellPut("shou", -13611); 銆銆spellPut("shu", -13601); 銆銆spellPut("shua", -13406); 銆銆spellPut("shuai", -13404); 銆銆spellPut("shuan", -13400); 銆銆spellPut("shuang", -13398); 銆銆spellPut("shui", -13395); 銆銆spellPut("shun", -13391); 銆銆spellPut("shuo", -13387); 銆銆spellPut("si", -13383); 銆銆spellPut("song", -13367); 銆銆spellPut("sou", -13359); 銆銆spellPut("su", -13356); 銆銆spellPut("suan", -13343); 銆銆spellPut("sui", -13340); 銆銆spellPut("sun", -13329); 銆銆spellPut("suo", -13326); 銆銆spellPut("ta", -13318); 銆銆spellPut("tai", -13147); 銆銆spellPut("tan", -13138); 銆銆spellPut("tang", -13120); 銆銆spellPut("tao", -13107); 銆銆spellPut("te", -13096); 銆銆spellPut("teng", -13095); 銆銆spellPut("ti", -13091); 銆銆spellPut("tian", -13076); 銆銆spellPut("tiao", -13068); 銆銆spellPut("tie", -13063); 銆銆spellPut("ting", -13060); 銆銆spellPut("tong", -12888); 銆銆spellPut("tou", -12875); 銆銆spellPut("tu", -12871); 銆銆spellPut("tuan", -12860); 銆銆spellPut("tui", -12858); 銆銆spellPut("tun", -12852); 銆銆spellPut("tuo", -12849); 銆銆spellPut("wa", -12838); 銆銆spellPut("wai", -12831); 銆銆spellPut("wan", -12829); 銆銆spellPut("wang", -12812); 銆銆spellPut("wei", -12802); 銆銆spellPut("wen", -12607); 銆銆spellPut("weng", -12597); 銆銆spellPut("wo", -12594); 銆銆spellPut("wu", -12585); 銆銆spellPut("xi", -12556); 銆銆spellPut("xia", -12359); 銆銆spellPut("xian", -12346); 銆銆spellPut("xiang", -12320); 銆銆spellPut("xiao", -12300); 銆銆spellPut("xie", -12120); 銆銆spellPut("xin", -12099); 銆銆spellPut("xing", -12089); 銆銆spellPut("xiong", -12074); 銆銆spellPut("xiu", -12067); 銆銆spellPut("xu", -12058); 銆銆spellPut("xuan", -12039); 銆銆spellPut("xue", -11867); 銆銆spellPut("xun", -11861); 銆銆spellPut("ya", -11847); 銆銆spellPut("yan", -11831); 銆銆spellPut("yang", -11798); 銆銆spellPut("yao", -11781); 銆銆spellPut("ye", -11604); 銆銆spellPut("yi", -11589); 銆銆spellPut("yin", -11536); 銆銆spellPut("ying", -11358); 銆銆spellPut("yo", -11340); 銆銆spellPut("yong", -11339); 銆銆spellPut("you", -11324); 銆銆spellPut("yu", -11303); 銆銆spellPut("yuan", -11097); 銆銆spellPut("yue", -11077); 銆銆spellPut("yun", -11067); 銆銆spellPut("za", -11055); 銆銆spellPut("zai", -11052); 銆銆spellPut("zan", -11045); 銆銆spellPut("zang", -11041); 銆銆spellPut("zao", -11038); 銆銆spellPut("ze", -11024); 銆銆spellPut("zei", -11020); 銆銆spellPut("zen", -11019); 銆銆spellPut("zeng", -11018); 銆銆spellPut("zha", -11014); 銆銆spellPut("zhan", -10832); 銆銆spellPut("zhang", -10815); 銆銆spellPut("zhao", -10800); 銆銆spellPut("zhe", -10790); 銆銆spellPut("zhen", -10780); 銆銆spellPut("zheng", -10764); 銆銆spellPut("zhi", -10587); 銆銆spellPut("zhong", -10544); 銆銆spellPut("zhou", -10533); 銆銆spellPut("zhu", -10519); 銆銆spellPut("zhua", -10331); 銆銆spellPut("zhuai", -10329); 銆銆spellPut("zhuan", -10328); 銆銆spellPut("zhuang", -10322); 銆銆spellPut("zhui", -10315); 銆銆spellPut("zhun", -10309); 銆銆spellPut("zhuo", -10307); 銆銆spellPut("zi", -10296); 銆銆spellPut("zong", -10281); 銆銆spellPut("zou", -10274); 銆銆spellPut("zu", -10270); 銆銆spellPut("zuan", -10262); 銆銆spellPut("zui", -10260); 銆銆spellPut("zun", -10256); 銆銆spellPut("zuo", -10254); 銆銆} 銆銆/** 銆銆* 鑾峰緱鍗曚釜姹夊瓧鐨凙scii. 銆銆* @param cn char 銆銆* 姹夊瓧瀛楃 銆銆* @return int 銆銆* 閿欒榪斿洖 0,鍚﹀垯榪斿洖ascii 銆銆*/ 銆銆public static int getCnAscii(char cn) 銆銆{ 銆銆byte[] bytes = (String.valueOf(cn)).getBytes(); 銆銆if(bytes == null || bytes.length > 2 || bytes.length <= 0){ //閿欒 銆銆return 0; 銆銆} 銆銆if(bytes.length == 1){ //鑻辨枃瀛楃 銆銆return bytes[0]; 銆銆} 銆銆if(bytes.length == 2){ //涓枃瀛楃 銆銆int hightByte = 256 + bytes[0]; 銆銆int lowByte = 256 + bytes[1]; 銆銆int ascii = (256 * hightByte + lowByte) - 256 * 256; 銆銆//System.out.println("ASCII=" + ascii); 銆銆return ascii; 銆銆} 銆銆return 0; //閿欒 銆銆} 銆銆/** 銆銆* 鏍規嵁ASCII鐮佸埌SpellMap涓煡鎵懼搴旂殑鎷奸煶 銆銆* @param ascii int 銆銆* 瀛楃瀵瑰簲鐨凙SCII 銆銆* @return String 銆銆* 鎷奸煶,棣栧厛鍒ゆ柇ASCII鏄惁>0&<160,濡傛灉鏄繑鍥炲搴旂殑瀛楃, 銆銆* 銆銆鍚﹀垯鍒癝pellMap涓煡鎵?濡傛灉娌℃湁鎵懼埌鎷奸煶,鍒欒繑鍥瀗ull,濡傛灉鎵懼埌鍒欒繑鍥炴嫾闊? 銆銆*/ 銆銆public static String getSpellByAscii(int ascii) 銆銆{ 銆銆if(ascii > 0 && ascii < 160){ //鍗曞瓧絎?/p> 銆銆return String.valueOf((char)ascii); 銆銆} 銆銆if(ascii < -20319 || ascii > -10247){ //涓嶇煡閬撶殑瀛楃 銆銆return null; 銆銆} 銆銆Set keySet = spellMap.keySet(); 銆銆Iterator it = keySet.iterator(); 銆銆String spell0 = null;; 銆銆String spell = null; 銆銆int asciiRang0 = -20319; 銆銆int asciiRang; 銆銆while(it.hasNext()){ 銆銆spell = (String)it.next(); 銆銆Object valObj = spellMap.get(spell); 銆銆if(valObj instanceof Integer){ 銆銆asciiRang = ((Integer)valObj).intValue(); 銆銆if(ascii >= asciiRang0 && ascii < asciiRang){ //鍖洪棿鎵懼埌 銆銆return(spell0 == null) ? spell : spell0; 銆銆} 銆銆else{ 銆銆spell0 = spell; 銆銆asciiRang0 = asciiRang; 銆銆} 銆銆} 銆銆} 銆銆return null; 銆銆} 銆銆* 榪斿洖瀛楃涓茬殑鍏ㄦ嫾,鏄眽瀛楄漿鍖栦負鍏ㄦ嫾,鍏跺畠瀛楃涓嶈繘琛岃漿鎹?/p> 銆銆* @param cnStr String 銆銆* 瀛楃涓?/p> 銆銆* @return String 銆銆* 杞崲鎴愬叏鎷煎悗鐨勫瓧絎︿覆 銆銆*/ 銆銆public static String getFullSpell(String cnStr) 銆銆{ 銆銆if(null == cnStr || "".equals(cnStr.trim())){ 銆銆return cnStr; 銆銆} 銆銆char[] chars = cnStr.toCharArray(); 銆銆StringBuffer retuBuf = new StringBuffer(); 銆銆for(int i = 0,Len = chars.length;i < Len;i++){ 銆銆int ascii = getCnAscii(chars); 銆銆if(ascii == 0){ //鍙朼scii鏃跺嚭閿?/p> 銆銆retuBuf.append(chars); 銆銆} 銆銆else{ 銆銆String spell = getSpellByAscii(ascii); 銆銆if(spell == null){ 銆銆retuBuf.append(chars); 銆銆} 銆銆else{ 銆銆retuBuf.append(spell); 銆銆} // end of if spell == null 銆銆} // end of if ascii <= -20400 銆銆} // end of for 銆銆return retuBuf.toString(); 銆銆} 銆銆public static String getFirstSpell(String cnStr) 銆銆{ 銆銆return null; 銆銆} 銆銆public static void main(String[] args) 銆銆{ 銆銆String str = null; 銆銆str = "璋㈡搗101鏅檷鍠滈洦"; 銆銆System.out.println("Spell=" + CnToSpell.getFullSpell(str)); 銆銆str = "寮犵墮鑸炵埅銆嬨傦紝"; 銆銆System.out.println("Spell=" + CnToSpell.getFullSpell(str)); 銆銆str = "鈻♀枴鈻♀枴錛屽彲鑰諱笅鍦恒?; 銆銆System.out.println("Spell=" + CnToSpell.getFullSpell(str)); 銆銆str = "鐚補錛岀尓鍏垝銆?; 銆銆System.out.println("Spell=" + CnToSpell.getFullSpell(str)); 銆銆} 銆銆}
/**button action listener to convert text to pinyin from one textbox to another textbox*/
private CnToSpell()
spellPut("dang", -19023);
spellPut("kuo", -16216);
spellPut("se", -13910);
spellPut("zhai", -10838);
/**
]]>
絎竴姝ワ細鍦ㄥ伐紼嬩腑鍔犲叆log4j鎵浣跨敤鐨刯ar鏂囦歡
1:欏圭洰 >聽
4:鍥炲埌欏圭洰鐨勫睘鎬х獥鍙o紝鐐瑰嚮紜畾
絎簩姝ワ細鍒涘緩log4j.properties鏂囦歡
1:閫夋嫨嬈蹭嬌鐢╨og4j鐨勯」鐩?gt;?鍙抽敭鐐瑰嚮src >?鏂板緩>?鍏朵粬 錛氬脊鍑洪夋嫨鍚戝紿楀彛
2:鍦ㄩ夋嫨鍚戝紿楀彛涓紝閫夋嫨甯歌?> 鏂囦歡?> 涓嬩竴姝ワ細寮瑰嚭鏂板緩鏂囦歡鐨勭獥鍙?br />3:鍦ㄦ柊寤烘枃浠剁獥鍙d腑錛岃緭鍏ユ枃浠跺悕log4j.properties ? 瀹屾垚錛氬垱寤哄伐浣滅粨鏉?br />絎笁姝ワ細浣跨敤log4j璁板綍鏃ュ織淇℃伅
import org.apache.log4j.Logger;
public class Log4j {
聽
聽
聽
聽
聽
聽
聽
聽
}
絎洓姝ワ細緙栧啓log4j.properties鏂囦歡錛岄厤緗棩蹇椾俊鎭?/p>
### 鎶婃棩蹇椾俊鎭緭鍑哄埌鎺у埗鍙?###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender//鏃ュ織淇℃伅灝嗗啓鍒版帶鍒跺彴
log4j.appender.stdout.Target=System.out//淇℃伅鎵撳嵃鍒癝ystem.out涓娐?wbr>
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}聽
### 鎶婃棩蹇椾俊鎭緭鍑哄埌鏂囦歡錛歛ccp.log ###
log4j.appender.file=org.apache.log4j.FileAppender//鏃ュ織淇℃伅灝嗗啓鍒版枃浠朵腑聽
log4j.appender.file.File=accp.log//鎸囧畾鏃ュ織杈撳嚭鐨勬枃浠跺悕聽
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}聽
### 璁劇疆浼樺厛綰у埆銆佷互鍙婅緭鍑烘簮 ###
log4j.rootLogger=debug, stdout, file//璁劇疆浼樺厛綰у埆涓篸ebug銆?br />鏃ュ織琚緭鍑哄埌澶氫釜杈撳嚭婧?/p>
娉細浼樺厛綰т粠楂樺埌浣庡垎鍒槸ERROR銆乄ARN銆両NFO銆丏EBUG
鍦ㄦ澶勶紝濡傛灉浼樺厛綰у埆璁句負info錛岄偅涔堜嬌鐢╠ebug鏂規硶鎵撳嵃鐨勬棩蹇椾俊鎭皢涓嶈杈撳嚭
鐩?褰?/td> | 鎻?榪?/td> |
/bin | 瀛樻斁鍦╓indows騫沖彴 浠ュ強Linux騫沖彴涓婂惎鍔?鍜屽叧闂璗omcat鐨勮剼鏈枃浠?/td> |
/conf | 瀛樻斁Tomcat鏈嶅姟鍣ㄧ殑鍚勭閰嶇疆鏂囦歡錛?鍏朵腑鏈閲嶈鐨勯厤緗枃浠舵槸server.xml |
/server | 鍖呭惈3涓瓙鐩綍: classes銆乴ib鍜寃ebapps |
/server/lib | 瀛樻斁Tomcat鏈嶅姟鍣ㄦ墍闇鐨勫悇縐岼AR鏂囦歡 |
/server/webapps | 瀛樻斁Tomcat鑷甫鐨勪袱涓猈eb搴旂敤: admin搴旂敤鍜宮anager搴旂敤 |
/common/lib | 瀛樻斁Tomcat鏈嶅姟鍣ㄤ互鍙婃墍鏈?Web搴旂敤閮藉彲浠ヨ闂殑JAR鏂囦歡 |
/shared/lib | 瀛樻斁鎵鏈塛eb搴旂敤閮藉彲浠ヨ闂殑JAR鏂囦歡 |
/logs | 瀛樻斁Tomcat鐨勬棩蹇楁枃浠?/td> |
/webapps | 褰撳彂甯僕eb搴旂敤鏃訛紝 榛樿鎯呭喌涓嬫妸Web搴旂敤 鏂囦歡鏀句簬姝ょ洰褰曚笅 |
/work | Tomcat鎶婄敱JSP鐢熸垚鐨?Servlet鏀句簬姝ょ洰褰曚笅 |
鐩?褰?/td> | 鎻?榪?/td> |
/helloapp | Web搴旂敤鐨勬牴鐩綍錛?鎵鏈夌殑JSP鍜孒TML鏂囦歡 閮藉瓨鏀句簬姝ょ洰褰曚笅 |
/helloapp/WEB-INF | 瀛樻斁Web搴旂敤鐨勫彂甯冩弿榪版枃浠秝eb.xml |
/helloapp/WEB-INF/classes | 瀛樻斁鍚勭class鏂囦歡錛?Servlet綾繪枃浠朵篃鏀句簬姝ょ洰褰曚笅 |
/helloapp/WEB-INF/lib | 瀛樻斁Web搴旂敤鎵闇鐨勫悇縐岼AR鏂囦歡 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
<!-- Define the default virtual host --> |
灞?鎬?/td> | 鎻?榪?/td> |
path | 鎸囧畾璁塊棶璇eb搴旂敤鐨刄RL鍏ュ彛 |
docBase | 鎸囧畾Web搴旂敤鐨勬枃浠惰礬寰勶紝鍙互緇欏畾緇濆璺緞錛屼篃鍙互緇欏畾鐩稿浜嶩ost鐨刟ppBase灞炴х殑鐩稿璺緞錛堝叧浜嶩ost鐨刟ppBase灞炴у弬瑙?.3鑺傦級銆傚鏋淲eb搴旂敤閲囩敤寮鏀劇洰褰曠粨鏋勶紝鍒欐寚瀹歐eb搴旂敤鐨勬牴鐩綍錛涘鏋淲eb搴旂敤鏄釜WAR鏂囦歡錛屽垯鎸囧畾WAR鏂囦歡鐨勮礬寰?/td> |
reloadable | 濡傛灉榪欎釜灞炴ц涓簍rue錛?Tomcat鏈嶅姟鍣ㄥ湪榪愯鐘舵佷笅浼氱洃瑙嗗湪WEB-INF/classes 鍜學EB-INF/lib鐩綍涓媍lass鏂囦歡鐨勬敼鍔ㄣ傚鏋滅洃嫻嬪埌鏈塩lass鏂囦歡琚洿鏂幫紝鏈嶅姟鍣ㄤ細鑷姩閲嶆柊鍔犺澆Web搴旂敤 |