#start#
chg_l
add_neighbor 4 6 0 0 0 29526 11883 4 6 0 0 0 29526 44293 internal
/*这些东西不用理会什么意思,当普通文字就行了*/
@12345@16951$wuyidadao$
/*这里的拼音wuyidadao要换成中文"五一大道",这个中文来源是根据前面的@12345@里的值12345检索数据库得到。这种“$,@”符号为了方便操作可以自己任意定*/
yes
yes
yes
0
5
5
1
5
#start#
chg_ladd_neighbor 4 6 0 0 0 29494 29812 4 6 0 0 0 29494 44982 external
|12345|16951|China Moble| /*同上,英语换成中文“中国移动通信”*/
yes
yes
yes
2
84
21
33
5/*下面可能还有多段这样的鬼东东*/
本来想贴一段代码,可是我发现我根本无法往下做,各位朋友帮忙想想.
chg_l
add_neighbor 4 6 0 0 0 29526 11883 4 6 0 0 0 29526 44293 internal
/*这些东西不用理会什么意思,当普通文字就行了*/
@12345@16951$wuyidadao$
/*这里的拼音wuyidadao要换成中文"五一大道",这个中文来源是根据前面的@12345@里的值12345检索数据库得到。这种“$,@”符号为了方便操作可以自己任意定*/
yes
yes
yes
0
5
5
1
5
#start#
chg_ladd_neighbor 4 6 0 0 0 29494 29812 4 6 0 0 0 29494 44982 external
|12345|16951|China Moble| /*同上,英语换成中文“中国移动通信”*/
yes
yes
yes
2
84
21
33
5/*下面可能还有多段这样的鬼东东*/
本来想贴一段代码,可是我发现我根本无法往下做,各位朋友帮忙想想.
费点事,但是基本可以实现
其实你可以换个角度,想办法把数据库里面的东西读进XML文档,就好操作了.
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MainChang {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
ChangCellName("E:\\mml\\","t.txt");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static String strSql = "" ;
/*
* ChangCellName(String,String)
* 解析文本文件
*/
public static String ChangCellName (String strPath,String strFileName) throws Exception{
BufferedReader reader=
new BufferedReader(new FileReader(new File(strPath+strFileName)));
String line=null;
StringBuffer writeSb=new StringBuffer();
while((line=reader.readLine())!=null){
//Pattern p= Pattern.compile("\\w+\\s*\\$(\\w+)\\|(\\d+)\\|(\\d+)\\|(\\w+)\\|(\\w+)\\$\\s*\\w+");
Pattern p=Pattern.compile("\\w+\\s*\\$(\\d+)\\-(\\d+)\\-(\\d+)\\-(\\d+)\\|(\\w+)$\\s*\\w+");
Matcher match = p.matcher(line);
if ( match.matches() ) {//是否找到匹配项
int gnum=match.groupCount();
String sChinese="";
String strValue[]=new String[gnum+1];
if(gnum > 0 ){
//将值分放入数组
for(int g=0 ; g<=gnum ; g ++){
strValue[g]=match.group(g);
System.out.println("strValue[g]:"+strValue[g]);
}
//判断是否增加邻区的指令
if(strValue[gnum].equals("true") || strValue[gnum].equals("TRUE") ){
/*是增加邻区的指令*/
//拼写是否在当天已经加过的SQL语句
strSql="select * from T_LIST_TEMP where bsc='"+strValue[1]+"' and ";
strSql+= "LAC='"+strValue[2]+"' and ";
strSql+= "ci='"+strValue[3]+"'";
//判断该指令是否在当天已经加过
if(QueryData.getBQueryList(strSql)){
//已经加过则删除指令
line = "";
}else{
//没有加过则加入
String site="";
String nbl ="";
String cellname="";
strSql="insert into t_list_temp(id,bsc,lac,ci,site,nbl,cell_name) " ;
strSql+=" values(SEQ_T_OMC_DATA.NEXTVAL,'"+strValue[1]+"','";
strSql+=strValue[2]+"','"+strValue[3]+"','"+strValue[4]+"','"+nbl+"','"+cellname+"')";
boolean bTrue = QueryData.intoTmp(strSql);
strSql = "select * from T_OMC_DATA where BSC='"+strValue[1]+"' and ";
strSql+= "LAC='"+strValue[2]+"' and ";
strSql+= "ci='"+strValue[3]+"'";
sChinese = QueryData.getChinese(strSql);
line = line.replaceAll("\\$(\\w+)\\|(\\d+)\\|(\\d+)\\|(\\w+)\\|(\\w+)\\$",sChinese);
}
}else{/*不是增加邻区的指令*/
//拼写查找对应对应中文的SQL语句
strSql = "select * from T_OMC_DATA where BSC='"+strValue[1]+"' and ";
strSql+= "LAC='"+strValue[2]+"' and ";
strSql+= "ci='"+strValue[3]+"'";
sChinese = QueryData.getChinese(strSql);
line = line.replaceAll("\\$(\\w+)\\|(\\d+)\\|(\\d+)\\|(\\w+)\\|(\\w+)\\$",sChinese);
}
}
}
//line=line.replaceAll("■","\n");
writeSb.append(line);
writeSb.append("\n");
}
FileOutputStream os=new FileOutputStream(strPath+"mml\\"+strFileName);
os.write(writeSb.toString().getBytes("gbk"));
return null ;
}
}
/*这样的话,基本已经解决了,还有一个问题是怎么分解这段
String line="lsienmertwelos $460-00-12345-23451|CSMBSC703$ keio" ;
我想把460-00-12345-23451这个取出来,还有CSMBSC703取出来放到数组,该怎么做啊?
*/