Java tutorial
/************************************************** * Filename: Test.java * Version: v1.0 * CreatedDate: 2011-12-29 * Copyright (C) 2011 By cafebabe. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * * If you would like to negotiate alternate licensing terms, you may do * so by contacting the author: talentyao@foxmail.com ***************************************************/ package com.ywh.train; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import com.ywh.train.bean.TrainQueryInfo; /** * ?? * @author YAOWENHAO * @since 2011-11-23 * @version 1.0 */ public class Test { public static void main(String[] args) throws Exception { List<NameValuePair> parameters = new ArrayList<NameValuePair>(); parameters.add(new BasicNameValuePair("includeStudent", "00")); parameters.add(new BasicNameValuePair("orderRequest.from_station_telecode", "SHH")); parameters.add(new BasicNameValuePair("orderRequest.start_time_str", "00:00--24:00")); parameters.add(new BasicNameValuePair("orderRequest.to_station_telecode", "CSQ")); parameters.add(new BasicNameValuePair("orderRequest.train_date", "2011-11-24")); parameters.add(new BasicNameValuePair("orderRequest.train_no", "")); parameters.add(new BasicNameValuePair("seatTypeAndNum", "")); parameters.add(new BasicNameValuePair("trainClass", "QB#D#Z#T#K#QT#")); parameters.add(new BasicNameValuePair("trainPassType", "QB")); String responseBody = "0,<span id='id_5l0000D10502' class='base_txtdiv' onmouseover=javascript:onStopHover('5l0000D10502#AOH#CSQ') onmouseout='onStopOut()'>D105</span>,<img src='/otsweb/images/tips/first.gif'> <br> 09:08,<img src='/otsweb/images/tips/last.gif'> <br> 18:21,09:13,--,--,<font color='darkgray'></font>,<font color='#008800'></font>,--,--,--,--,--,--,--,<input type='button' class='yuding_u' onmousemove=this.className='yuding_u_over' onmousedown=this.className='yuding_u_down' onmouseout=this.className='yuding_u' onclick=javascript:getSelected('D105#553#09:08#5l0000D10502#AOH#CSQ') value=''></input>," + "<span id='id_5l0000D10502' class='base_txtdiv' onmouseover=javascript:onStopHover('5l0000D10502#EPH#PXG') onmouseout='onStopOut()'>D105</span>, ? <br> 09:38, ?? <br> 17:09,07:31,--,--,<font color='darkgray'></font>,<font color='darkgray'></font>,--,--,--,--,--,--,--,<input type='button' class='yuding_x' value=''></input>"; List<TrainQueryInfo> tqis = Util.parserQueryInfo(responseBody); for (TrainQueryInfo tqi : tqis) { System.out.println(tqi); } String citys = "@bji||BJP|0@bjn|?|VNP|1@bjx||BXP|2@cqb|?|CUW|3@sha||SHH|4@shn|?|SNH|5@shq||AOH|6@shx||SXH|7@tji||TJP|8@tjn|?|TIP|9@tjx||TXP|10@cch||CCT|11@cdd|?|ICW|12@cdu|?|CDW|13@csh||CSQ|14@csn|?|CWQ|15@fzh|?|FZS|16@fzn|??|FYS|17@gzb||GBQ|18@gzd||GGQ|19@gzh||GZQ|20@gzn|?|IZQ|21@heb||HBB|22@hfe|?|HFH|23@hkd|?|HMQ|24@hko|?|VUQ|25@hzh|?|HZH|26@hzn|??|XHH|27@jna|?|JNK|28@jnd|?|JAK|29@jnx|?|JGK|30@lzh||LZJ|31@nch|?|NCG|32@nji|?|NJH|33@njn|??|NKH|34@sjb||VVP|35@sjz||SJP|36@sya||SYT|37@syb||SBT|38@tyu||TYV|39@wha||WHN|40@xab||EAY|41@xan||XAY|42@zzh||ZZF|43@aya||AYF|44@bbu||BBH|45@bji|?|BJY|46@cna|??|CEH|47@czh||CZH|48@djy||DDW|49@dli||DLT|50@dsq||DQT|51@dzh||RXW|52@fdi|?|FES|53@han||AUH|54@hda||HDP|55@hko|?|HKN|56@hnx|?|EUH|57@hsh||HSP|58@hsh||HSN|59@jan|?|VAG|60@jgs||JGG|61@jhx|?|JBH|62@jji|?|JJG|63@jli|?|JLL|64@jsh||JUH|65@kfe|?|KFF|66@ksn|?|KNH|67@lan||UAH|68@lhe||LON|69@ljy|?|LKP|70@lym||LLF|71@lzh||LZD|72@nbd|?|NVH|73@nch|?|NCW|74@nto|?|NUH|75@pxi|??|PXG|76@pxx||PCW|77@qcs|?|QSW|78@qda|?|QDK|79@qzh||QEH|80@qzh||QYS|81@shg||SHD|82@sni|??|NIW|83@spi||SPT|84@sqi||SQF|85@sra||SRG|86@sya|??|SNN|87@sya||SEQ|88@szh|?|SZN|89@szh|?|SZH|90@szh||SZQ|91@tgu||TGP|92@tli|?|TLT|93@tsb|?|FUP|94@tsh|?|TSP|95@wch||WCN|96@wfd||WDT|97@wna|?|WNY|98@wxi||WXH|99@wys||WAS|100@wzn|?|VRH|101@xch||XCF|102@xhu||EFQ|103@xmb||XKS|104@xme||XMS|105@xxi||XXF|106@xya||XUN|107@xya||XFN|108@xyu||XUG|109@xzh|?|XCH|110@yan||YWY|111@ych|?|AFH|112@ych||YCG|113@yta||YTG|114@ywu||YWH|115@yxi||YON|116@yzh||YLH|117@zbo|?|ZBK|118@zhb|?|ZIQ|119@zji||ZJH|120@zmd||ZDN|121@zzh||ZZQ|122@zzh||ZEK|123@zzx||ZFK|124@aji||ARH|125@atb||ASH|126@bao|?|BWQ|127@bbn|?|BMH|128@bdh||BEP|129@bdi|?|BDP|130@bhs|??|BWH|131@bji||IBQ|132@bji||BLQ|133@cbb|?|CIN|134@cle|?|CLK|135@czb||ESH|136@czh|?|CXH|137@czx||ICQ|138@czx||CBP|139@dan||DAG|140@dgu||DAQ|141@dsh|?|DRQ|142@dtu||RUH|143@dya||DYH|144@dyb||EXH|145@dyd||IAW|146@dyu||EWH|147@dzd||DIP|148@dzh||DXP|149@ezh||ECN|150@fan|?|FAS|151@fdo||FIH|152@fhu||FHH|153@fqi|?|FQS|154@gmi||GMK|155@gqc|?|GAG|156@gyn|?|GYF|157@gzh|?|GNQ|158@hax||HIH|159@hax||VXN|160@hch|??|WKW|161@hgz||IGW|162@hji||HJS|163@hlb||HPD|164@hni|?|HNH|165@hqi||VQH|166@hsb|?|HDY|167@hsh||VCH|168@hsx||HEQ|169@hyd||HVQ|170@hzh||VON|171@jji||JJS|172@jme||JWQ|173@jsb||EGH|174@jsn|?|EAH|175@jxi||JXH|176@jxn|?|EPH|177@jzb||JZK|178@jzh||JZH|179@jzn|?|JOD|180@lbx|??|LPF|181@lch|?|UCK|182@lfa|?|LJP|183@lha||UFH|184@lji||LKS|185@lsh|?|LSG|186@lsh||LIQ|187@lxi||UXP|188@lyo||LMH|189@lyu|?|LVS|190@lyx||LPQ|191@mcb||MBN|192@mcn|?|MNF|193@mla||MHQ|194@mld||MQQ|195@nde|?|NES|196@nha|?|NHH|197@nla|?|NNQ|198@nxb|?|NEH|199@pjb||PBD|200@pti||PTS|201@qfd||QAK|202@qha|?|QYQ|203@qji||INH|204@qsy||QYH|205@qyu||QBQ|206@qzs|?|QZK|207@ran||RAH|208@rch||RCG|209@rgu||RUQ|210@sde||ORQ|211@sfa|?|OLH|212@sgu||SNQ|213@sjn|??|IMH|214@slo||SLQ|215@smn|?|SCF|216@smx||OQH|217@sxi|?|SOH|218@syu||BDH|219@szb||SND|220@szb|?|OHH|221@szd||SRH|222@szq|?|ITH|223@szq|?|KAH|224@tan|?|TID|225@tan||TMK|226@tms||TLS|227@tna|?|TVW|228@txi|?|TCH|229@tzd||TEK|230@tzh|?|TZH|231@wch||WEQ|232@wfa|??|WFK|233@wli||VHH|234@wnb|?|WBY|235@wni|?|WNQ|236@wqi||WWP|237@wxd||WGH|238@wxq||IFH|239@xga|?|XGN|240@xla|?|EAQ|241@xli||XPH|242@xnb|?|XRN|243@xpu||XOS|244@xpu||XIW|245@xta|?|XTP|246@xzd|?|UUH|247@ych||AIH|248@yds|??|YGH|249@yha|?|EVH|250@yji||URH|251@ylw||TWQ|252@ylz|?|YSY|253@yqb||YPP|254@yqi|?|UPH|255@yxi||ACG|256@yya||YYH|257@yyd||YIQ|258@zji||ZDH|259@zjn|?|ZEH|260@zmt||ZOQ|261@zqi||ZTK|262@zsb||ZGQ|263@zsh||ZSQ|264@zzx||ZAQ|265"; String city[] = citys.split("@"); System.out.println("---------start--------"); for (String tmp : city) { System.out.println(tmp); } System.out.println("---------end--------"); //String test = "? ? ?? ? ? ? ? --> ?? ??? : 260.0()--> ? Sat Nov 26 14:04:16 CST 2011 1 ? ?? ? ? Mon Nov 28 00:00:00 CST 2011 D105 Thu Jan 01 09:08:00 CST 1970 02 052 ?, 260.0 ? --> --> ??"; String test = "1 vxv"; System.out.println(test.replaceAll("\\s", "")); } }