62,623
社区成员
发帖
与我相关
我的任务
分享
/**
* project_name: Test
* package_name: netsource
* package_declaration: package netsource;
* filename: DateOpposite.java
* author: yuhaiming
* date: 2007-11-14
*/
/**
* 目前数据库里这样两字段
上班 001
迟到 ¦早退 ¦休假 a1 ¦a2 ¦a3
我现在想实现
上班-001
迟到-a1,早退-a2,休假-a3
这样的数据怎么合并??
*/
package netsource;
import java.io.*;
public class DateOpposite {
public static void disposal(String strvalue1,String strvalue2){
String strresult = "";
int count1 =-1,count2=-1;
while((count1 =strvalue1.indexOf("¦"))>0&&(count2 =strvalue2.indexOf("¦"))>0){
strresult += strvalue1.substring(0,count1).trim()+"-"+strvalue2.substring(0,count2).trim()+"&";
strvalue1 = strvalue1.substring(count1+1);
strvalue2 = strvalue2.substring(count2+1);
}
strresult += strvalue1+"-"+strvalue2;
String[] result = strresult.split("&");
display(result);
}
public static void display(String[] result){
for(int i=0;i<result.length;i++){
System.out.println(result[i]);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String strvalue1 = "迟到 ¦早退 ¦休假";//从数据库取值,这里为了方便直接赋值了
String strvalue2 = "a1 ¦a2 ¦a3";//从数据库取值,这里为了方便直接赋值了
disposal(strvalue1,strvalue2);
}
}
public class test {
public test() {
String a = "123|234|345";
String b[] = a.split("|");
for(String c:b)
System.out.println(c);
}
public static void main(String[] args) {
new test();
}
}