这样的字段里怎么取值??

greenjia0 2007-11-14 10:44:54
122
123|254|
258|36958|
147
125487|369854|
12574
125487|2569894|4587545|58475|
...全文
148 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
jedzy 2008-07-25
  • 打赏
  • 举报
回复
学习
seaforce 2007-11-14
  • 打赏
  • 举报
回复
只供参考,写得不好的地方还忘见谅
------------------------------------

/**
* 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);
}

}

greenjia0 2007-11-14
  • 打赏
  • 举报
回复
目前数据库里这样两字段

上班 001
迟到|早退|休假 a1|a2|a3


我现在想实现

上班-001
迟到-a1,早退-a2,休假-a3


这样的数据怎么合并??
JadoNet 2007-11-14
  • 打赏
  • 举报
回复
没看明白,帮你顶!
asphebby 2007-11-14
  • 打赏
  • 举报
回复
目前数据库里这样两字段

上班 001
迟到 ¦早退 ¦休假 a1 ¦a2 ¦a3


我现在想实现

上班-001
迟到-a1,早退-a2,休假-a3


这样的数据怎么合并??


select t.上班 || '-' || t.001 from table t
Kreocn 2007-11-14
  • 打赏
  • 举报
回复
...........程序写错了....失误啊......
上面的 a.split("|")应该是a.split("\\|");
忘了转义字符了....
Kreocn 2007-11-14
  • 打赏
  • 举报
回复
晕....不用这么麻烦吧.....


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();
}
}


可以招这样的思路做
greenjia0 2007-11-14
  • 打赏
  • 举报
回复
我看看谢谢了

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧