package dao;
public class StringConvertArray {
public String[][] convertArray(String s){
String s1=s.replace('"', ' ');
s1=s1.trim();
String s2[]=s1.split("}");
//System.out.println(s1+" :"+s2.length);
String s4[][] = new String[s2.length-1][];
for(int i=0;i<s2.length-1;i++){
String s3=s2[i].substring(2,s2[i].length());
//System.out.println(s3+"AOOOOOOOO");
s4[i]=s3.split(",");
//System.out.println(s4[i].length);
}
String updateArray[][]=s4;
for(int i=0;i<s4.length;i++){
for(int j=0;j<s4[i].length;j++){
updateArray[i][j]=(s4[i][j].substring(s4[i][j].indexOf(":")+1,s4[i][j].length())).trim();
System.out.println("KKKKKKKKKKKKKk:"+updateArray[i][j]);
}
}
return updateArray;
}
}
、、、、、、、、、、、、、
public void save(String s[][]){
try{
session=HibernateUtil.getSessionFactory().getCurrentSession();
}catch(HibernateException e){
session=HibernateUtil.getSessionFactory().openSession();
};
try{
Transaction tx = session.beginTransaction();
for(int i=0;i<s.length;i++){
AssetInfo assetInfo=(AssetInfo)session.load(AssetInfo.class, s[i][0]);
assetInfo.setModel(s[i][1]);
Date date = null;
try{
SimpleDateFormat bartDateFormat =new SimpleDateFormat("yyyy-MM-dd");
date=bartDateFormat.parse(s[i][2]);
}catch(Exception e){
System.out.println("时间转换错误");
e.printStackTrace();
}
assetInfo.setProduceDate(date);
assetInfo.setName(s[i][3]);
session.update(assetInfo);
}
tx.commit();
}catch(Exception ex){
ex.printStackTrace();
}
}